/* ==========================================================================
   Mes routines duo — deux moitiés, deux routines en parallèle
   ========================================================================== */

/* ---------- Polices ---------- */
@font-face {
  font-family: 'Baloo 2';
  font-style: normal;
  font-weight: 400 800;
  font-display: swap;
  src: url('../assets/fonts/baloo-2-latin-ext.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF,
    U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020,
    U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'Baloo 2';
  font-style: normal;
  font-weight: 400 800;
  font-display: swap;
  src: url('../assets/fonts/baloo-2-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA,
    U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193,
    U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Nunito';
  font-style: normal;
  font-weight: 400 900;
  font-display: swap;
  src: url('../assets/fonts/nunito-latin-ext.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF,
    U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020,
    U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'Nunito';
  font-style: normal;
  font-weight: 400 900;
  font-display: swap;
  src: url('../assets/fonts/nunito-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA,
    U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193,
    U+2212, U+2215, U+FEFF, U+FFFD;
}

/* ---------- Base ---------- */
:root {
  --paper: #fffdf8;
  --ink: #3c2a1c;
  --muted: #7c6a58;
  --line: #e9dfcd;
  --purple: #592b83;
  --gold: #edb02c;
  --green: #2fa84f;
  --green-dark: #1e7a38;
  --font-display: 'Baloo 2', ui-rounded, 'Trebuchet MS', sans-serif;
  --font-body: 'Nunito', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --shadow-paper: 0 2px 0 rgba(255, 255, 255, 0.65) inset,
    0 16px 32px rgba(72, 45, 16, 0.24), 0 3px 8px rgba(72, 45, 16, 0.12);
  --noise: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.06'/%3E%3C/svg%3E");
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
}

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

body {
  font-family: var(--font-body);
  color: var(--ink);
  background-color: #c79a67;
  background-image:
    radial-gradient(ellipse 260px 110px at 14% 16%, rgba(96, 58, 20, 0.18), transparent 70%),
    radial-gradient(ellipse 200px 80px at 84% 72%, rgba(96, 58, 20, 0.14), transparent 70%),
    radial-gradient(ellipse 150px 60px at 62% 32%, rgba(96, 58, 20, 0.1), transparent 70%),
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.045) 0 2px, transparent 2px 7px),
    repeating-linear-gradient(90deg, transparent 0 169px, rgba(94, 57, 22, 0.2) 169px 172px, transparent 172px 341px),
    linear-gradient(180deg, #d3a97a 0%, #c79a67 46%, #b3864f 100%);
  overflow: hidden;
  overscroll-behavior: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  touch-action: manipulation;
}

body::after {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 9000;
  background-image: var(--noise);
  pointer-events: none;
}

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

button {
  font: inherit;
  color: inherit;
}

img {
  -webkit-user-drag: none;
  user-select: none;
}

.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;
}

:focus-visible {
  outline: 4px solid #ffd166;
  outline-offset: 3px;
}

/* ---------- Thèmes ---------- */
.theme-bleu {
  --accent: #2f7fc1;
  --accent-soft: #e3f2fd;
  --accent-dark: #1c5c92;
}
.theme-rose {
  --accent: #d15488;
  --accent-soft: #fde8f1;
  --accent-dark: #9d2f5e;
}
.theme-matin {
  --pcolor: #d99a15;
  --psoft: #fff3d1;
  --pdark: #8a5f00;
}
.theme-midi {
  --pcolor: #2f9e6b;
  --psoft: #e4f7ed;
  --pdark: #1d6b47;
}
.theme-soir {
  --pcolor: #5b5bd6;
  --psoft: #ecebfc;
  --pdark: #3b3ba6;
}

/* ---------- Structure ---------- */
.app {
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: 10px 10px 0;
  padding-top: max(10px, env(safe-area-inset-top));
  padding-left: max(10px, env(safe-area-inset-left));
  padding-right: max(10px, env(safe-area-inset-right));
}

.duo {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: clamp(10px, 1.5vmin, 18px);
}

/* ---------- Moitiés ---------- */
.pane {
  position: relative;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  isolation: isolate;
  container-type: size;
  container-name: pane;
  border-radius: clamp(18px, 2.4vmin, 30px);
  border: 1px solid rgba(255, 255, 255, 0.72);
  background-color: var(--paper);
  background-image:
    radial-gradient(110% 42% at 50% 0%, var(--accent-soft) 0%, rgba(255, 253, 248, 0) 70%),
    linear-gradient(180deg, #ffffff 0%, var(--paper) 58%, #fbf6ec 100%);
  box-shadow: var(--shadow-paper);
}

.pane::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 5;
  height: clamp(4px, 0.7vmin, 7px);
  background: var(--accent);
  pointer-events: none;
}

.pane::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 0;
  border-radius: inherit;
  background-image: var(--noise);
  pointer-events: none;
  opacity: 0.75;
}

.pane-view {
  position: relative;
  z-index: 2;
  height: 100%;
  display: flex;
  flex-direction: column;
  gap: clamp(5px, 1.2cqh, 12px);
  padding: 12px;
  padding: clamp(9px, 2.2cqh, 18px);
  animation: view-in 0.3s ease both;
}

@keyframes view-in {
  from {
    opacity: 0;
    transform: translateY(7px) scale(0.995);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.pane-doodle {
  position: absolute;
  z-index: 1;
  color: var(--gold);
  opacity: 0.9;
  pointer-events: none;
  filter: drop-shadow(0 1px 0 rgba(255, 255, 255, 0.55));
}
.pane-doodle svg {
  display: block;
  width: 100%;
  height: 100%;
  fill: currentColor;
}
.pane-doodle--1 {
  top: 12%;
  right: 9%;
  width: clamp(14px, 2.2cqw, 26px);
  height: clamp(14px, 2.2cqw, 26px);
  transform: rotate(14deg);
}
.pane-doodle--2 {
  bottom: 10%;
  left: 8%;
  width: clamp(10px, 1.6cqw, 19px);
  height: clamp(10px, 1.6cqw, 19px);
  transform: rotate(-12deg);
  opacity: 0.65;
}

.pane-tape {
  position: absolute;
  top: clamp(9px, 1.8cqh, 16px);
  left: 50%;
  z-index: 3;
  width: clamp(82px, 17cqw, 130px);
  height: clamp(20px, 3.4cqh, 32px);
  transform: translateX(-50%) rotate(-2deg);
  background-color: var(--accent-soft);
  background-color: color-mix(in srgb, var(--accent) 24%, #ffffff);
  background-image: repeating-linear-gradient(
    45deg,
    rgba(255, 255, 255, 0.55) 0 6px,
    transparent 6px 13px
  );
  box-shadow: 0 2px 5px rgba(80, 50, 20, 0.15);
  clip-path: polygon(2% 8%, 98% 0, 100% 90%, 0 100%);
  pointer-events: none;
}

/* ---------- Menu d'un enfant ---------- */
.pane-menu {
  padding: clamp(8px, 1.6cqh, 16px);
}

.menu-btn {
  flex: 1;
  min-height: 0;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  gap: clamp(4px, 1.15cqh, 12px);
  padding: 10px;
  padding: clamp(8px, 2cqh, 20px);
  border: 0;
  border-radius: clamp(14px, 2cqh, 24px);
  background: transparent;
  text-align: center;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.12s ease;
}

.menu-btn:active {
  transform: scale(0.992);
}

.menu-avatar {
  width: min(29cqw, 24cqh);
  aspect-ratio: 1;
  flex: none;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: radial-gradient(circle at 34% 26%, #ffffff 0%, var(--accent-soft) 100%);
  border: clamp(3px, 0.55vmin, 6px) solid #ffffff;
  box-shadow: 0 0 0 clamp(2px, 0.32vmin, 4px) var(--accent-soft),
    0 10px 22px rgba(72, 45, 16, 0.15);
}

.menu-avatar img {
  width: 72%;
  height: 72%;
  object-fit: contain;
}

.menu-hello {
  display: block;
  font-size: clamp(10px, 1.9cqh, 16px);
  font-weight: 900;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--muted);
}

.menu-name {
  display: block;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(40px, min(18cqw, 15cqh), 130px);
  line-height: 0.88;
  letter-spacing: -0.012em;
  color: var(--accent);
  text-shadow: 0 2px 0 rgba(255, 255, 255, 0.8);
}

.menu-underline {
  display: block;
  width: clamp(90px, 25cqw, 230px);
  height: clamp(7px, 1.5cqh, 16px);
  margin-top: calc(-1 * clamp(3px, 0.6cqh, 8px));
  color: var(--accent);
  opacity: 0.45;
}
.menu-underline svg {
  display: block;
  width: 100%;
  height: 100%;
}

.menu-chips {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: clamp(4px, 0.7cqh, 9px);
  margin-top: clamp(1px, 0.3cqh, 4px);
}

.menu-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35em;
  padding: clamp(3px, 0.7cqh, 7px) clamp(8px, 1.5cqw, 15px);
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-dark);
  font-weight: 800;
  font-size: clamp(10px, min(2.1cqw, 1.8cqh), 16px);
  white-space: nowrap;
}
.menu-chip img {
  width: 1.4em;
  height: 1.4em;
}

.menu-today {
  display: flex;
  align-items: center;
  gap: 0.4em;
  font-size: clamp(10px, 1.7cqh, 15px);
  font-weight: 700;
  color: var(--muted);
  text-wrap: balance;
}
.menu-today .star {
  width: 1.05em;
  height: 1.05em;
  flex: none;
  fill: var(--gold);
}

.menu-cta {
  display: inline-flex;
  align-items: center;
  gap: 0.45em;
  margin-top: clamp(3px, 0.9cqh, 10px);
  padding: clamp(8px, 1.5cqh, 14px) clamp(18px, 3.2cqw, 32px);
  border-radius: 999px;
  background: var(--accent);
  color: #ffffff;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(14px, min(2.8cqw, 2.4cqh), 22px);
  line-height: 1;
  box-shadow: 0 4px 0 var(--accent-dark), 0 10px 18px rgba(72, 45, 16, 0.2);
  white-space: nowrap;
}

.menu-cta svg {
  width: 1.1em;
  height: 1.1em;
  fill: currentColor;
}

.menu-btn:active .menu-cta {
  transform: translateY(3px);
  box-shadow: 0 1px 0 var(--accent-dark), 0 5px 10px rgba(72, 45, 16, 0.16);
}

/* ---------- En-tête commun ---------- */
.pane-head,
.routine-head {
  flex: none;
  display: flex;
  align-items: center;
  gap: clamp(5px, 1.1cqw, 12px);
  min-height: clamp(36px, 6.6cqh, 54px);
}

.icon-btn {
  flex: none;
  display: grid;
  place-items: center;
  width: clamp(36px, 6cqh, 50px);
  height: clamp(36px, 6cqh, 50px);
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent-dark);
  box-shadow: 0 3px 0 rgba(130, 95, 50, 0.11);
  cursor: pointer;
  transition: transform 0.12s ease, background 0.15s ease;
}
.icon-btn:hover {
  background: #ffffff;
}
.icon-btn:active {
  transform: scale(0.93);
}
.icon-btn svg {
  width: 48%;
  height: 48%;
  fill: currentColor;
}

.pane-head__avatar {
  flex: none;
  width: clamp(24px, 5.2cqh, 38px);
  height: clamp(24px, 5.2cqh, 38px);
  object-fit: contain;
}

.pane-head__title {
  flex: 1;
  min-width: 0;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(15px, min(3.2cqw, 3.6cqh), 28px);
  line-height: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.pane-head__title .name {
  color: var(--accent);
}

.pane-head__stats {
  flex: none;
  display: flex;
  align-items: center;
  gap: 0.35em;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(12px, 2cqh, 19px);
  color: var(--accent-dark);
  white-space: nowrap;
}
.pane-head__stats .star {
  width: 1em;
  height: 1em;
  flex: none;
  fill: var(--gold);
}

/* ---------- Choix du moment ---------- */
.period-list {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: clamp(6px, 1.3cqh, 12px);
}

.period-choice {
  position: relative;
  flex: 1;
  min-height: 0;
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  gap: clamp(7px, 1.5cqw, 16px);
  padding: 10px;
  padding: clamp(7px, 1.5cqh, 16px) clamp(9px, 1.7cqw, 20px) clamp(7px, 1.5cqh, 16px)
    clamp(11px, 2cqw, 22px);
  border: 1px solid var(--line);
  border-radius: clamp(12px, 2cqh, 20px);
  background-color: var(--paper);
  background-image: linear-gradient(
    100deg,
    var(--psoft) 0%,
    #ffffff 45%,
    var(--paper) 100%
  );
  box-shadow: 0 4px 0 rgba(180, 150, 100, 0.09), 0 8px 16px rgba(72, 45, 16, 0.1);
  text-align: left;
  cursor: pointer;
  overflow: hidden;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.period-choice::before {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: clamp(4px, 0.8vmin, 7px);
  background: var(--pcolor);
}

.period-choice:hover {
  transform: translateY(-1px);
  box-shadow: 0 5px 0 rgba(180, 150, 100, 0.1), 0 12px 20px rgba(72, 45, 16, 0.13);
}
.period-choice:active {
  transform: scale(0.993);
}

.period-choice__icon {
  flex: none;
  width: min(17cqw, 19cqh);
  aspect-ratio: 1;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: radial-gradient(circle at 36% 28%, #ffffff 0%, var(--psoft) 100%);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.9),
    0 0 0 clamp(2px, 0.3vmin, 4px) rgba(255, 255, 255, 0.6),
    0 6px 12px rgba(72, 45, 16, 0.08);
}
.period-choice__icon img {
  width: 66%;
  height: 66%;
  object-fit: contain;
}

.period-choice__text {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: clamp(1px, 0.35cqh, 4px);
}

.period-choice__label {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(22px, min(6.2cqw, 5.4cqh), 46px);
  line-height: 0.95;
  color: var(--pdark);
  letter-spacing: -0.01em;
}

.period-choice__time {
  font-weight: 800;
  font-size: clamp(10px, min(2.4cqw, 2cqh), 17px);
  color: var(--muted);
}

.period-choice__tagline {
  font-size: clamp(10px, min(2.1cqw, 1.8cqh), 15px);
  font-weight: 600;
  color: var(--muted);
  line-height: 1.15;
}

.period-choice__side {
  flex: none;
  width: clamp(84px, 23cqw, 180px);
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  justify-content: center;
  gap: clamp(3px, 0.7cqh, 7px);
}

.period-choice__badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3em;
  padding: clamp(3px, 0.55cqh, 6px) clamp(7px, 1.2cqw, 12px);
  border-radius: 999px;
  font-size: clamp(8px, min(1.9cqw, 1.5cqh), 13px);
  font-weight: 900;
  line-height: 1;
  white-space: nowrap;
  box-shadow: 0 2px 0 rgba(72, 45, 16, 0.1);
}
.period-choice__badge svg {
  width: 1em;
  height: 1em;
  fill: currentColor;
}
.period-choice__badge--now {
  background: #ffd75e;
  color: #4b3200;
  transform: rotate(1.5deg);
}
.period-choice__badge--done {
  background: var(--green-dark);
  color: #ffffff;
}

.period-choice__count {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(10px, min(2.2cqw, 1.8cqh), 16px);
  color: var(--pdark);
  white-space: nowrap;
}

.period-choice__bar {
  width: 100%;
  height: clamp(5px, 0.9cqh, 9px);
  border-radius: 999px;
  background: #efe7d8;
  overflow: hidden;
  box-shadow: inset 0 1px 2px rgba(90, 60, 25, 0.12);
}
.period-choice__bar span {
  display: block;
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--pcolor), var(--pdark));
  transition: width 0.4s ease;
}
.period-choice.is-complete {
  border-color: #cfe6d5;
}
.period-choice.is-complete .period-choice__bar span {
  background: linear-gradient(90deg, #3ebd63, var(--green-dark));
}

/* ---------- Routine ---------- */
.pane-routine {
  padding: 10px;
  padding: clamp(7px, 1.7cqh, 15px);
  gap: clamp(4px, 1cqh, 9px);
}

.routine-head {
  min-height: clamp(34px, 6.2cqh, 50px);
}

.routine-title {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: clamp(4px, 0.9cqw, 10px);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(15px, min(3.3cqw, 3.4cqh), 30px);
  line-height: 1;
  color: var(--purple);
  letter-spacing: -0.01em;
}

.routine-title__icon {
  flex: none;
  width: clamp(24px, 4.8cqh, 38px);
  height: clamp(24px, 4.8cqh, 38px);
  object-fit: contain;
  filter: drop-shadow(0 2px 3px rgba(72, 45, 16, 0.1));
}

.routine-title__text {
  min-width: 0;
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding-right: 0.2em;
}
.routine-title .name {
  color: var(--accent);
}

.routine-meta {
  flex: none;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
  min-width: clamp(74px, 14cqw, 130px);
}

.stars-row {
  display: flex;
  align-items: center;
  gap: 1.5px;
}

.pstar {
  width: clamp(10px, 1.75cqh, 16px);
  height: clamp(10px, 1.75cqh, 16px);
  fill: #e8ddc9;
  transition: fill 0.2s ease, transform 0.2s ease;
  flex: none;
}
.pstar.is-on {
  fill: var(--gold);
  filter: drop-shadow(0 1px 0 rgba(150, 100, 0, 0.2));
}
.pstar.is-pop {
  animation: star-pop 0.44s cubic-bezier(0.2, 0.9, 0.3, 1.4);
}
@keyframes star-pop {
  0% {
    transform: scale(0.6);
  }
  55% {
    transform: scale(1.35);
  }
  100% {
    transform: scale(1);
  }
}

.routine-meta__count {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(12px, 1.9cqh, 19px);
  line-height: 1;
  color: var(--ink);
  white-space: nowrap;
}
.routine-meta__count b {
  color: var(--accent);
  font-weight: 800;
}

.routine-bar {
  width: 100%;
  height: clamp(4px, 0.7cqh, 7px);
  border-radius: 999px;
  background: #efe7d8;
  overflow: hidden;
  box-shadow: inset 0 1px 2px rgba(90, 60, 25, 0.12);
}
.routine-bar span {
  display: block;
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), var(--accent-dark));
  transition: width 0.4s ease;
}

.steps-grid {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: repeat(var(--cols, 2), minmax(0, 1fr));
  grid-template-rows: repeat(var(--rows, 4), minmax(0, 1fr));
  gap: clamp(5px, 1.1cqh, 10px);
}

.step-card {
  position: relative;
  container-type: size;
  min-width: 0;
  min-height: 0;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  cursor: pointer;
  perspective: 1000px;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  transition: transform 0.12s ease;
}
.step-card:active {
  transform: scale(0.975);
}

.step-card__inner {
  position: absolute;
  inset: 0;
  transform-style: preserve-3d;
  transition: transform 0.55s cubic-bezier(0.18, 0.85, 0.28, 1.05);
}
.step-card.is-done .step-card__inner {
  transform: rotateY(180deg);
}

.step-card__face {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: clamp(6px, 4.6cqw, 18px) clamp(5px, 3.6cqw, 16px) clamp(10px, 6.5cqh, 22px);
  border-radius: clamp(10px, 2cqh, 18px);
  border: 1px solid #eadfce;
  background-color: var(--paper);
  box-shadow: 0 3px 0 rgba(180, 150, 100, 0.09), 0 8px 16px rgba(72, 45, 16, 0.12);
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  overflow: hidden;
}
.step-card__face::after {
  content: '';
  position: absolute;
  inset: 0;
  background-image: var(--noise);
  pointer-events: none;
  border-radius: inherit;
}

.step-card__back {
  transform: rotateY(180deg);
  border-color: #cfe6d5;
  background-color: #fbfffc;
  background-image: linear-gradient(180deg, #ffffff 0%, #f3fdf6 100%);
  box-shadow: 0 3px 0 rgba(47, 168, 79, 0.11), 0 8px 16px rgba(72, 45, 16, 0.1);
}

.peg {
  position: absolute;
  left: 50%;
  z-index: 2;
  width: clamp(5px, 2.3cqw, 11px);
  aspect-ratio: 1;
  transform: translateX(-50%);
  border-radius: 50%;
  background: #f4ede1;
  border: 1px solid #dfd3bf;
  box-shadow: inset 0 2px 4px rgba(95, 65, 30, 0.22), 0 1px 0 #ffffff;
  pointer-events: none;
}
.peg--top {
  top: clamp(4px, 2.2cqh, 9px);
}
.peg--bottom {
  bottom: clamp(4px, 2.2cqh, 9px);
}

.step-card__art {
  width: min(54cqw, 42cqh);
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  flex: none;
}
.step-card__art img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 4px 4px rgba(70, 40, 10, 0.11));
}

.step-card__label {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(10px, 7cqw, 22px);
  line-height: 1.06;
  letter-spacing: -0.005em;
  text-align: center;
  text-wrap: balance;
  color: #463324;
  margin-top: clamp(2px, 1.6cqh, 8px);
  max-width: 100%;
  hyphens: auto;
}

.step-card__check {
  width: min(60cqw, 50cqh);
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  transform: rotate(-3deg);
  flex: none;
}

.check-svg {
  width: 100%;
  height: 100%;
  overflow: visible;
}
.check-svg__halo {
  stroke: var(--green);
  stroke-width: 22;
  stroke-linecap: round;
  stroke-linejoin: round;
  fill: none;
  opacity: 0.14;
}
.check-svg__path {
  stroke: var(--green);
  stroke-width: 14;
  stroke-linecap: round;
  stroke-linejoin: round;
  fill: none;
  stroke-dasharray: 150;
  stroke-dashoffset: 150;
}
.step-card.is-done .check-svg__path {
  stroke-dashoffset: 0;
  transition: stroke-dashoffset 0.45s cubic-bezier(0.3, 0.8, 0.3, 1) 0.2s;
}

.step-card__done-label {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(9px, 5cqw, 16px);
  line-height: 1.05;
  text-align: center;
  color: var(--green-dark);
  margin-top: clamp(1px, 0.8cqh, 5px);
  max-width: 100%;
  text-wrap: balance;
}

.step-card.just-done .step-card__inner {
  animation: card-pop 0.5s cubic-bezier(0.2, 0.9, 0.3, 1.3);
}
@keyframes card-pop {
  0% {
    transform: rotateY(0deg) scale(1);
  }
  55% {
    transform: rotateY(180deg) scale(1.045);
  }
  100% {
    transform: rotateY(180deg) scale(1);
  }
}

.routine-foot {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: clamp(5px, 1cqw, 12px);
  padding-top: clamp(5px, 0.9cqh, 10px);
  border-top: 1px dashed #e6dccb;
}

.foot-hint {
  display: flex;
  align-items: center;
  gap: 0.4em;
  font-size: clamp(9px, 1.45cqh, 13px);
  font-weight: 700;
  color: var(--muted);
}
.foot-hint svg {
  width: 1.2em;
  height: 1.2em;
  flex: none;
  fill: var(--gold);
}
.foot-hint.is-complete {
  color: var(--green-dark);
}
.foot-hint.is-complete svg {
  fill: var(--green);
}

.mini-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4em;
  min-height: clamp(30px, 4.8cqh, 42px);
  padding: 0 clamp(9px, 1.5cqw, 15px);
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #ffffff;
  color: #8a5a2b;
  font-weight: 800;
  font-size: clamp(10px, 1.5cqh, 14px);
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 3px 0 rgba(130, 95, 50, 0.1);
  white-space: nowrap;
  transition: transform 0.12s ease, background 0.15s ease;
}
.mini-btn:hover {
  background: var(--accent-soft);
}
.mini-btn:active {
  transform: translateY(2px);
  box-shadow: none;
}
.mini-btn svg {
  width: 1.1em;
  height: 1.1em;
  fill: currentColor;
  flex: none;
}

/* ---------- Bravo / confirmation dans la moitié ---------- */
.pane-celebrate {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: clamp(14px, 4cqw, 34px);
  background: rgba(48, 30, 12, 0.46);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  border-radius: inherit;
}
.pane-celebrate[hidden] {
  display: none;
}

.celebrate-card {
  position: relative;
  width: min(94%, 560px);
  padding: clamp(14px, 3.2cqh, 34px) clamp(14px, 3.2cqw, 34px);
  border-radius: clamp(16px, 2.6cqh, 28px);
  background-color: var(--paper);
  background-image:
    radial-gradient(90% 60% at 50% 0%, #fff7dc 0%, rgba(255, 253, 248, 0) 72%),
    linear-gradient(180deg, #ffffff, var(--paper));
  box-shadow: 0 24px 50px rgba(40, 22, 5, 0.42), 0 2px 0 rgba(255, 255, 255, 0.8) inset;
  text-align: center;
  transform: scale(0.86) rotate(-1.5deg);
  opacity: 0;
  transition: transform 0.35s cubic-bezier(0.2, 0.9, 0.3, 1.12), opacity 0.25s ease;
}
.pane-celebrate.is-open .celebrate-card {
  transform: scale(1) rotate(0deg);
  opacity: 1;
}

.celebrate-stars {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(2px, 0.5cqw, 7px);
  margin-bottom: clamp(2px, 0.6cqh, 7px);
}
.celebrate-stars .star {
  width: clamp(18px, 4.2cqh, 38px);
  height: clamp(18px, 4.2cqh, 38px);
  fill: var(--gold);
  filter: drop-shadow(0 2px 0 rgba(150, 100, 0, 0.16));
  animation: star-twinkle 1.3s ease-in-out infinite alternate;
}
.celebrate-stars .star:nth-child(2) {
  width: clamp(28px, 6.4cqh, 56px);
  height: clamp(28px, 6.4cqh, 56px);
  animation-delay: 0.2s;
}
.celebrate-stars .star:nth-child(3) {
  animation-delay: 0.4s;
}
@keyframes star-twinkle {
  from {
    transform: scale(0.92) rotate(-4deg);
  }
  to {
    transform: scale(1.06) rotate(4deg);
  }
}

.celebrate-title {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(28px, 7cqh, 62px);
  line-height: 0.98;
  color: var(--purple);
  letter-spacing: -0.015em;
}
.celebrate-title .name {
  color: var(--accent);
}
.celebrate-title--small {
  font-size: clamp(24px, 5.6cqh, 48px);
}

.celebrate-text {
  margin-top: clamp(4px, 1cqh, 10px);
  font-size: clamp(12px, 2.2cqh, 19px);
  font-weight: 700;
  color: var(--muted);
  text-wrap: balance;
}

.celebrate-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-top: clamp(12px, 2.4cqh, 24px);
  padding: clamp(8px, 1.5cqh, 14px) clamp(22px, 3.6cqw, 40px);
  border: 0;
  border-radius: 999px;
  background: var(--green);
  color: #ffffff;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(15px, 2.4cqh, 24px);
  line-height: 1;
  box-shadow: 0 5px 0 var(--green-dark), 0 12px 20px rgba(72, 45, 16, 0.22);
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}
.celebrate-btn:active {
  transform: translateY(3px);
  box-shadow: 0 2px 0 var(--green-dark), 0 6px 12px rgba(72, 45, 16, 0.18);
}

.confirm-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: clamp(6px, 1.2cqw, 12px);
  margin-top: clamp(12px, 2.2cqh, 24px);
}
.confirm-actions .celebrate-btn {
  margin-top: 0;
  padding: clamp(8px, 1.3cqh, 13px) clamp(14px, 2.4cqw, 26px);
  font-size: clamp(13px, 2cqh, 20px);
}

.celebrate-btn--small {
  background: #e58a3a;
  box-shadow: 0 4px 0 #a85c1a, 0 10px 18px rgba(72, 45, 16, 0.2);
}
.celebrate-btn--ghost {
  background: #ffffff;
  color: var(--ink);
  border: 1px solid var(--line);
  box-shadow: 0 4px 0 rgba(130, 95, 50, 0.13);
}
.celebrate-btn--ghost:active {
  box-shadow: 0 1px 0 rgba(130, 95, 50, 0.13);
}

/* ---------- Confettis dans la moitié ---------- */
.pane-confetti {
  position: absolute;
  inset: 0;
  z-index: 30;
  overflow: hidden;
  pointer-events: none;
  border-radius: inherit;
}

.confetti {
  position: absolute;
  top: -10%;
  width: 8px;
  height: 12px;
  border-radius: 2px;
  animation: pane-fall linear forwards;
}
@keyframes pane-fall {
  to {
    top: 110%;
    transform: translate3d(var(--drift, 0), 0, 0) rotate(720deg);
  }
}

.spark {
  position: absolute;
  z-index: 2;
  width: clamp(10px, 2.4cqw, 18px);
  height: clamp(10px, 2.4cqw, 18px);
  pointer-events: none;
  transform: translate(-50%, -50%);
  animation: spark-fly 0.82s cubic-bezier(0.15, 0.7, 0.3, 1) forwards;
}
.spark .star {
  width: 100%;
  height: 100%;
  fill: currentColor;
}
@keyframes spark-fly {
  0% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(0.4) rotate(0deg);
  }
  100% {
    opacity: 0;
    transform: translate(calc(-50% + var(--dx, 0px)), calc(-50% + var(--dy, 0px)))
      scale(0.25) rotate(var(--rot, 0deg));
  }
}

/* ---------- Barre d'outils ---------- */
.toolbar {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(5px, 0.9vmin, 9px) 0;
  padding-bottom: max(clamp(5px, 0.9vmin, 9px), env(safe-area-inset-bottom));
}

.tools {
  display: flex;
  align-items: center;
  gap: clamp(5px, 0.8vmin, 9px);
  padding: clamp(4px, 0.7vmin, 7px) clamp(7px, 1.1vmin, 10px) clamp(4px, 0.7vmin, 7px)
    clamp(14px, 2vmin, 22px);
  border-radius: 999px;
  background: rgba(49, 33, 20, 0.9);
  color: #fff7e7;
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.18), 0 12px 26px rgba(45, 26, 8, 0.3);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(11px, 1.7vmin, 17px);
  letter-spacing: 0.03em;
  white-space: nowrap;
}

.tools__brand {
  display: inline-flex;
  align-items: center;
  gap: 0.45em;
}
.tools__star {
  width: 1em;
  height: 1em;
  fill: var(--gold);
  flex: none;
}
.tools__divider {
  width: 1px;
  height: 1.6em;
  background: rgba(255, 255, 255, 0.16);
  margin: 0 0.1em;
}

.tool-btn {
  display: grid;
  place-items: center;
  width: clamp(30px, 4.4vmin, 40px);
  height: clamp(30px, 4.4vmin, 40px);
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  color: inherit;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.12s ease;
}
.tool-btn:hover {
  background: rgba(255, 255, 255, 0.2);
}
.tool-btn:active {
  transform: scale(0.92);
}
.tool-btn svg {
  width: 55%;
  height: 55%;
  fill: currentColor;
}

/* ---------- Adaptation à la taille de chaque moitié ---------- */
@container pane (max-width: 540px) {
  .pane-head__stats {
    display: none;
  }
  .period-choice__tagline {
    display: none;
  }
  .routine-meta .stars-row {
    display: none;
  }
  .foot-hint {
    display: none;
  }
  .routine-foot {
    justify-content: flex-end;
  }
}

@container pane (max-height: 560px) {
  .menu-hello {
    display: none;
  }
  .menu-chips {
    display: none;
  }
  .period-choice__tagline {
    display: none;
  }
  .foot-hint {
    display: none;
  }
  .routine-foot {
    justify-content: flex-end;
  }
  .pane-doodle {
    display: none;
  }
}

@container pane (max-height: 470px) {
  .menu-today {
    display: none;
  }
  .menu-underline {
    display: none;
  }
  .period-choice__time {
    display: none;
  }
  .pane-tape {
    display: none;
  }
}

@container pane (max-width: 430px) {
  .mini-btn span {
    display: none;
  }
  .period-choice__side {
    width: clamp(70px, 22cqw, 100px);
  }
}

/* ---------- Portrait (secours) ---------- */
@media (orientation: portrait) {
  .duo {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr 1fr;
  }
}

/* ---------- Accessibilité / mouvement ---------- */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}

.noscript {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-weight: 800;
}
