:root {
  /* Backgrounds (light, warm) */
  --bg: #fbf6ee;
  --bg-elev: #ffffff;
  --bg-elev-2: #f3ecdc;
  --line: #ead9c0;
  /* Text */
  --ink: #1d2433;
  --ink-soft: #5a6478;
  --ink-faint: #9aa3b8;
  /* Accents */
  --teal: #0db89c;
  --teal-rgb: 13, 184, 156;
  --teal-deep: #086b5a;
  --amber: #e8a128;
  --amber-rgb: 232, 161, 40;
  --rose: #e8526a;
  --rose-rgb: 232, 82, 106;
  --green: #2ec27e;
  --green-rgb: 46, 194, 126;
  --purple: #9b6dff;
  --purple-rgb: 155, 109, 255;
  /* On-accent text (dark text on saturated accent backgrounds) */
  --on-accent: #0a1a20;
  /* Layout */
  --bar-h: 56px;
  --tab-h: 64px;
  --safe-bot: env(safe-area-inset-bottom, 0);
  --radius: 14px;
  --shadow-card: 0 1px 2px rgba(20, 30, 40, 0.04), 0 4px 12px rgba(20, 30, 40, 0.04);
  --shadow-card-hover: 0 2px 4px rgba(20, 30, 40, 0.06), 0 10px 24px rgba(20, 30, 40, 0.08);
  color-scheme: light;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0; padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, "Inter", sans-serif;
  font-size: 16px;
  line-height: 1.5;
  overflow-x: hidden;
  min-height: 100dvh;
}

button {
  font-family: inherit;
  font-size: inherit;
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
}

/* App bar */
.app-bar {
  position: sticky; top: 0; z-index: 10;
  height: var(--bar-h);
  display: grid; grid-template-columns: 44px 1fr 44px;
  align-items: center;
  padding: 0 8px;
  background: rgba(251, 246, 238, 0.85);
  backdrop-filter: saturate(180%) blur(16px);
  border-bottom: 1px solid var(--line);
}
.app-title {
  grid-column: 2;
  margin: 0;
  font-size: 1.1rem;
  font-weight: 600;
  text-align: center;
  letter-spacing: -0.01em;
  white-space: nowrap;
}
.back-btn { grid-column: 1; }
.info-btn { grid-column: 3; }
.back-btn, .info-btn {
  width: 44px; height: 44px;
  display: grid; place-items: center;
  color: var(--ink-soft);
  border-radius: 12px;
}
.back-btn:active, .info-btn:active { background: var(--bg-elev); }
[hidden] { display: none !important; }

/* Main screen container */
main.screens {
  padding: 16px 16px calc(var(--tab-h) + var(--safe-bot) + 24px);
  min-height: calc(100dvh - var(--bar-h));
}
.screen { display: block; }

/* Hero */
.hero { padding: 24px 4px 16px; }
.hero-eyebrow {
  margin: 0;
  font-size: 0.85rem;
  color: var(--teal);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
}
.hero-title {
  margin: 6px 0 0;
  font-size: 1.6rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.2;
}
.hero-sub {
  margin: 10px 0 0;
  color: var(--ink-soft);
  font-size: 0.95rem;
  line-height: 1.45;
}

/* Apparatus grid */
.apparatus-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-top: 16px;
}
.apparatus-card {
  position: relative;
  aspect-ratio: 1 / 1;
  display: flex; flex-direction: column;
  justify-content: space-between;
  padding: 16px;
  background: var(--bg-elev);
  border-radius: var(--radius);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-card);
  transition: transform 0.12s ease, box-shadow 0.12s ease;
  overflow: hidden;
}
.apparatus-card:active {
  transform: scale(0.97);
  box-shadow: var(--shadow-card-hover);
}
.apparatus-card::after {
  content: "";
  position: absolute; inset: 0;
  background: linear-gradient(135deg, transparent 55%, rgba(var(--teal-rgb), 0.10));
  pointer-events: none;
}
.apparatus-card[data-apparatus="vault"]::after { background: linear-gradient(135deg, transparent 55%, rgba(var(--amber-rgb), 0.15)); }
.apparatus-card[data-apparatus="vault"] .apparatus-card-symbol { color: var(--amber); }
.apparatus-card[data-apparatus="bars"]::after  { background: linear-gradient(135deg, transparent 55%, rgba(var(--teal-rgb), 0.15)); }
.apparatus-card[data-apparatus="bars"]  .apparatus-card-symbol { color: var(--teal); }
.apparatus-card[data-apparatus="beam"]::after  { background: linear-gradient(135deg, transparent 55%, rgba(var(--rose-rgb), 0.15)); }
.apparatus-card[data-apparatus="beam"]  .apparatus-card-symbol { color: var(--rose); }
.apparatus-card[data-apparatus="floor"]::after { background: linear-gradient(135deg, transparent 55%, rgba(var(--purple-rgb), 0.15)); }
.apparatus-card[data-apparatus="floor"] .apparatus-card-symbol { color: var(--purple); }
.apparatus-card-symbol {
  font-size: 2rem;
  font-weight: 700;
  color: var(--teal);
  letter-spacing: -0.04em;
}
.apparatus-card-label {
  font-size: 1.15rem;
  font-weight: 600;
}
.apparatus-card-sub {
  font-size: 0.75rem;
  color: var(--ink-soft);
  margin-top: -2px;
}
.apparatus-card-count {
  font-size: 0.8rem;
  color: var(--ink-faint);
}

/* Routine screen */
.routine-header {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px;
  padding: 4px 0 16px;
}
.routine-title-block {
  min-width: 0;
  flex: 1;
}
.routine-eyebrow {
  margin: 0 0 2px;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--teal);
  font-weight: 600;
}
.routine-title-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0;
  font-size: 1.3rem;
  font-weight: 600;
  color: var(--ink);
  letter-spacing: -0.01em;
  line-height: 1.15;
  max-width: 100%;
}
.routine-title-btn:active { opacity: 0.7; }
.routine-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.routine-chevron {
  flex-shrink: 0;
  color: var(--ink-soft);
}

/* Gestionnaire de routines */
.rmgmt-list {
  list-style: none;
  padding: 0;
  margin: 0 0 16px;
  display: grid;
  gap: 8px;
}
.rmgmt-item {
  background: var(--bg-elev-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
}
.rmgmt-item.current {
  border-color: var(--teal);
  background: rgba(var(--teal-rgb), 0.06);
}
.rmgmt-pick {
  width: 100%;
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  text-align: left;
}
.rmgmt-pick:active { background: rgba(20, 30, 40, 0.04); }
.rmgmt-info { min-width: 0; }
.rmgmt-name {
  font-size: 0.98rem;
  font-weight: 600;
  color: var(--ink);
  line-height: 1.3;
  overflow-wrap: anywhere;
}
.rmgmt-active {
  display: inline-block;
  margin-left: 6px;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--teal);
  background: rgba(var(--teal-rgb), 0.18);
  padding: 1px 6px;
  border-radius: 5px;
  vertical-align: 2px;
}
.rmgmt-meta {
  font-size: 0.78rem;
  color: var(--ink-soft);
  margin-top: 2px;
}
.rmgmt-chevron { color: var(--ink-faint); }
.rmgmt-actions {
  display: flex;
  gap: 1px;
  background: var(--line);
  padding: 0;
}
.rmgmt-action {
  flex: 1;
  padding: 8px;
  font-size: 0.8rem;
  font-weight: 500;
  background: var(--bg-elev);
  color: var(--ink-soft);
  text-align: center;
}
.rmgmt-action:active { background: var(--bg-elev-2); }
.rmgmt-action.danger { color: var(--rose); }
.note-d-display {
  text-align: right;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 6px 12px;
  min-width: 96px;
  cursor: pointer;
  box-shadow: var(--shadow-card);
}
.note-d-display:active { background: var(--bg-elev-2); }
@keyframes note-pulse {
  0%   { transform: scale(1); box-shadow: 0 0 0 0 rgba(var(--teal-rgb), 0); }
  35%  { transform: scale(1.06); box-shadow: 0 0 0 8px rgba(var(--teal-rgb), 0.18); }
  100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(var(--teal-rgb), 0); }
}
.note-d-display.note-pulse { animation: note-pulse 0.55s ease; }
.note-d-display.note-pulse .note-d-value { color: var(--green); }
.note-d-label {
  display: block;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-faint);
}
.note-d-value {
  display: block;
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--teal);
  letter-spacing: -0.02em;
}

/* Coachmark (tutoriel interactif) */
.coachmark {
  position: fixed; inset: 0;
  z-index: 500;
  pointer-events: none;
  animation: cm-fade 0.2s ease;
}
@keyframes cm-fade { from { opacity: 0; } to { opacity: 1; } }
.coachmark-spot {
  position: absolute;
  border-radius: 14px;
  box-shadow: 0 0 0 9999px rgba(20, 30, 40, 0.55);
  transition: top 0.3s ease, left 0.3s ease, width 0.3s ease, height 0.3s ease;
  pointer-events: none;
  outline: 3px solid var(--teal);
  outline-offset: 4px;
}
.coachmark-spot.centered {
  /* When no target, fully cover overlay */
  top: 50%; left: 50%;
  width: 0; height: 0;
  outline: none;
  box-shadow: 0 0 0 9999px rgba(20, 30, 40, 0.7);
}
@keyframes cm-pulse {
  0%, 100% { outline-color: var(--teal); }
  50% { outline-color: rgba(var(--teal-rgb), 0.4); }
}
.coachmark-spot:not(.centered) { animation: cm-pulse 1.6s ease-in-out infinite; }
.coachmark-tooltip {
  position: absolute;
  left: 16px; right: 16px;
  background: var(--bg-elev);
  border: 2px solid var(--teal);
  border-radius: 14px;
  padding: 14px 16px;
  box-shadow: 0 12px 36px rgba(20, 30, 40, 0.25);
  pointer-events: auto;
  max-width: 480px;
  margin: 0 auto;
}
.coachmark-counter {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--teal);
  font-weight: 700;
  margin-bottom: 6px;
}
.coachmark-text {
  margin: 0 0 14px;
  font-size: 0.98rem;
  line-height: 1.45;
  color: var(--ink);
}
.coachmark-text strong { color: var(--teal); }
.coachmark-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.coachmark-skip {
  font-size: 0.85rem;
  color: var(--ink-faint);
  padding: 6px 4px;
}
.coachmark-skip:active { color: var(--ink-soft); }
.coachmark-next {
  padding: 9px 20px;
  border-radius: 999px;
  background: var(--teal);
  color: #06181a;
  font-weight: 700;
  font-size: 0.9rem;
}
.coachmark-next:active { background: var(--teal-deep); color: var(--ink); }

/* Onboarding overlay (premier lancement) */
.onboarding {
  position: fixed; inset: 0;
  z-index: 1000;
  background: linear-gradient(160deg, #fef9f0 0%, #fbf6ee 50%, #f5ede0 100%);
  display: flex; flex-direction: column;
  padding-top: env(safe-area-inset-top, 0);
  padding-bottom: env(safe-area-inset-bottom, 0);
  animation: onb-fade 0.25s ease;
}
@keyframes onb-fade {
  from { opacity: 0; }
  to { opacity: 1; }
}
.onb-skip {
  position: absolute;
  top: calc(env(safe-area-inset-top, 0) + 14px);
  right: 16px;
  padding: 6px 14px;
  border-radius: 999px;
  background: rgba(20, 30, 40, 0.06);
  color: var(--ink-soft);
  font-size: 0.85rem;
  font-weight: 500;
  z-index: 2;
}
.onb-skip:active { background: rgba(20, 30, 40, 0.12); }
.onb-track {
  flex: 1;
  display: flex;
  overflow-x: auto;
  overflow-y: hidden;
  scroll-snap-type: x mandatory;
  scroll-behavior: smooth;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.onb-track::-webkit-scrollbar { display: none; }
.onb-slide {
  flex: 0 0 100%;
  width: 100%;
  min-width: 100%;
  scroll-snap-align: center;
  scroll-snap-stop: always;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 60px 28px 40px;
  text-align: center;
  gap: 18px;
}
.onb-illu {
  width: 160px; height: 160px;
  display: grid; place-items: center;
  color: var(--teal);
  background: rgba(var(--teal-rgb), 0.06);
  border-radius: 32px;
  border: 1px solid rgba(var(--teal-rgb), 0.18);
}
.onb-illu svg { width: 100%; height: 100%; padding: 22px; }
.onb-title {
  margin: 0;
  font-size: 1.7rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--ink);
}
.onb-text {
  margin: 0;
  max-width: 380px;
  font-size: 1.02rem;
  line-height: 1.5;
  color: var(--ink-soft);
}
.onb-text strong { color: var(--teal); font-weight: 600; }
.onb-steps {
  list-style: none;
  padding: 0;
  margin: 0;
  max-width: 380px;
  display: grid;
  gap: 12px;
  text-align: left;
  counter-reset: step;
}
.onb-steps li {
  position: relative;
  padding-left: 38px;
  font-size: 0.98rem;
  color: var(--ink-soft);
  line-height: 1.4;
  counter-increment: step;
}
.onb-steps li::before {
  content: counter(step);
  position: absolute; left: 0; top: -2px;
  width: 28px; height: 28px;
  display: grid; place-items: center;
  background: var(--teal);
  color: #06181a;
  border-radius: 50%;
  font-weight: 700;
  font-size: 0.9rem;
}
.onb-steps strong { color: var(--ink); font-weight: 600; }
.onb-cta-stack {
  width: 100%;
  max-width: 320px;
  display: grid;
  gap: 10px;
  margin-top: 8px;
}
.onb-cta {
  width: 100%;
  padding: 14px;
  border-radius: 12px;
  font-size: 1rem;
  font-weight: 600;
  background: var(--bg-elev);
  color: var(--ink);
  border: 1px solid var(--line);
}
.onb-cta.primary {
  background: var(--teal);
  color: #06181a;
  border-color: var(--teal);
  font-weight: 700;
}
.onb-cta:active { transform: scale(0.98); }
.onb-footer {
  padding: 14px 24px calc(20px + env(safe-area-inset-bottom, 0));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.onb-dots {
  display: flex; gap: 6px;
}
.onb-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: rgba(20, 30, 40, 0.15);
  transition: all 0.2s ease;
}
.onb-dot.active {
  background: var(--teal);
  width: 24px;
  border-radius: 4px;
}
.onb-next {
  padding: 10px 22px;
  border-radius: 999px;
  background: var(--teal);
  color: #06181a;
  font-weight: 700;
  font-size: 0.95rem;
}
.onb-next:active { background: var(--teal-deep); color: var(--ink); }
.onb-next[hidden] { display: none; }

/* Progress card (checklist routine) */
.progress-card {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-top: 16px;
  box-shadow: var(--shadow-card);
}
.progress-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.progress-title {
  margin: 0;
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--ink);
  letter-spacing: -0.01em;
}
.progress-counter {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--teal);
  background: rgba(var(--teal-rgb), 0.12);
  padding: 3px 10px;
  border-radius: 999px;
}
.progress-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 10px;
}
.progress-item {
  display: grid;
  grid-template-columns: 24px 1fr;
  gap: 12px;
  align-items: start;
}
.progress-tick {
  width: 24px; height: 24px;
  display: grid; place-items: center;
  border-radius: 50%;
  background: var(--bg-elev-2);
  color: var(--ink-faint);
  font-size: 0.95rem;
  font-weight: 700;
  border: 1.5px solid var(--line);
  line-height: 1;
}
.progress-item.done .progress-tick {
  background: var(--green);
  color: #06181a;
  border-color: var(--green);
}
.progress-item.done .progress-label { color: var(--ink-soft); text-decoration: line-through; text-decoration-color: var(--ink-faint); }
.progress-item.optional .progress-tick {
  background: var(--bg-elev);
  color: var(--ink-faint);
  border-style: dashed;
}
.progress-label {
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--ink);
  line-height: 1.3;
}
.progress-hint {
  font-size: 0.8rem;
  color: var(--ink-soft);
  line-height: 1.4;
  margin-top: 2px;
}

@keyframes celebrate-pop {
  0%   { transform: scale(0.85); opacity: 0; }
  60%  { transform: scale(1.04); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}
.progress-celebration {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 14px;
  align-items: center;
  background: linear-gradient(135deg, rgba(var(--green-rgb), 0.15), rgba(var(--teal-rgb), 0.1));
  border: 1px solid rgba(var(--green-rgb), 0.4);
  border-radius: var(--radius);
  padding: 16px 18px;
  animation: celebrate-pop 0.45s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes celebrate-spin {
  from { transform: rotate(-15deg); }
  to   { transform: rotate(0); }
}
.progress-celebration-icon { animation: celebrate-spin 0.5s ease-out; }
.progress-celebration-icon {
  width: 40px; height: 40px;
  display: grid; place-items: center;
  background: var(--green);
  color: #06181a;
  border-radius: 50%;
  font-size: 1.3rem;
  font-weight: 700;
}
.progress-celebration-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--ink);
}
.progress-celebration-sub {
  font-size: 0.85rem;
  color: var(--ink-soft);
  margin-top: 2px;
}

/* EC cards (parties obligatoires) */
.ec-strip {
  display: grid;
  gap: 8px;
  margin-bottom: 16px;
}
.ec-card {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 12px;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 14px;
  text-align: left;
  transition: all 0.15s ease;
  box-shadow: var(--shadow-card);
  width: 100%;
}
.ec-card:active { transform: scale(0.99); }
.ec-card-icon {
  width: 28px; height: 28px;
  display: grid; place-items: center;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 700;
}
.ec-card-body { display: flex; flex-direction: column; gap: 2px; }
.ec-card-label {
  font-size: 0.92rem;
  font-weight: 500;
  color: var(--ink);
  line-height: 1.25;
}
.ec-card-status {
  font-size: 0.75rem;
  color: var(--ink-faint);
}
.ec-card-status strong { color: inherit; font-weight: 600; }
.ec-card-arrow {
  color: var(--ink-faint);
  font-size: 1.2rem;
  line-height: 1;
}
.ec-card.filled {
  background: rgba(var(--green-rgb), 0.08);
  border-color: rgba(var(--green-rgb), 0.4);
}
.ec-card.filled .ec-card-icon {
  background: var(--green);
  color: #06181a;
}
.ec-card.filled .ec-card-status { color: var(--green); }
.ec-card.missing {
  background: rgba(var(--rose-rgb), 0.05);
  border-color: rgba(var(--rose-rgb), 0.3);
}
.ec-card.missing .ec-card-icon {
  background: rgba(var(--rose-rgb), 0.2);
  color: var(--rose);
}
.ec-card.missing .ec-card-status { color: var(--rose); }

/* Breakdown */
.breakdown {
  background: var(--bg-elev);
  border-radius: var(--radius);
  border: 1px solid var(--line);
  padding: 14px 16px;
  margin-bottom: 16px;
  display: grid;
  gap: 6px;
  font-size: 0.9rem;
}
.breakdown-row {
  display: flex; justify-content: space-between;
  color: var(--ink-soft);
}
.breakdown-row.total {
  border-top: 1px solid var(--line);
  padding-top: 8px;
  margin-top: 4px;
  color: var(--ink);
  font-weight: 600;
}
.breakdown-row .v { color: var(--ink); }

/* Sections repliables (parties obligatoires, détail de note) */
.collapse {
  margin-top: 16px;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
}
.collapse-summary {
  list-style: none;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 13px 16px;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
}
.collapse-summary::-webkit-details-marker { display: none; }
.collapse-title {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--ink);
}
.collapse-counter {
  font-size: 0.82rem;
  font-weight: 700;
  padding: 2px 10px;
  border-radius: 999px;
  background: rgba(var(--amber-rgb), 0.16);
  color: #8f6310;
}
.collapse-counter.all-done {
  background: rgba(var(--green-rgb), 0.16);
  color: var(--teal-deep);
}
.collapse-chevron {
  color: var(--ink-faint);
  flex-shrink: 0;
  transition: transform 0.2s ease;
}
.collapse[open] .collapse-chevron { transform: rotate(180deg); }
.collapse-body { padding: 0 12px 12px; }
.collapse .ec-strip { margin-bottom: 0; }
.collapse .breakdown {
  background: transparent;
  border: none;
  box-shadow: none;
  padding: 2px 4px 0;
  margin-bottom: 0;
}

/* Routine list */
.routine-elements { margin-top: 8px; }
.section-title {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-faint);
  margin: 16px 0 8px;
  font-weight: 600;
}
.section-title.with-help {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.help-btn,
.help-btn-inline {
  width: 22px; height: 22px;
  display: inline-grid; place-items: center;
  border-radius: 50%;
  background: var(--bg-elev-2);
  color: var(--ink-soft);
  font-size: 0.75rem;
  font-weight: 700;
  border: 1px solid var(--line);
  flex-shrink: 0;
}
.help-btn:active,
.help-btn-inline:active {
  background: var(--teal);
  color: #06181a;
}
.help-btn-inline {
  width: 18px; height: 18px;
  font-size: 0.65rem;
  margin-left: 4px;
  vertical-align: middle;
}
.routine-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.routine-item {
  display: grid;
  grid-template-columns: auto auto auto 1fr auto;
  align-items: center;
  gap: 10px;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  box-shadow: var(--shadow-card);
  transition: transform 180ms cubic-bezier(.2,.7,.3,1), box-shadow 180ms ease, opacity 180ms ease;
  position: relative;
  user-select: none;
  -webkit-user-select: none;
}
.routine-item-handle {
  display: inline-flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 4px;
  width: 28px;
  padding: 12px 6px;
  margin: -12px -6px -12px -8px;
  cursor: grab;
  color: var(--ink-faint);
  touch-action: none;
  border-radius: 6px;
  transition: background 150ms ease, color 150ms ease;
}
.routine-item-handle:active {
  background: var(--bg-elev-2);
  color: var(--teal);
  cursor: grabbing;
}
.routine-item-handle span {
  display: block;
  width: 14px;
  height: 2px;
  background: currentColor;
  border-radius: 1px;
}
.routine-item.dragging {
  z-index: 5;
  box-shadow: 0 14px 28px rgba(0,0,0,0.18), 0 4px 8px rgba(0,0,0,0.10);
  transform: scale(1.02);
  background: var(--bg-elev);
  border-color: var(--teal);
  transition: none;
}
.routine-list.drag-mode .routine-item:not(.dragging) {
  opacity: 0.85;
}

/* Connecteur entre 2 éléments — liaison candidate */
.liaison-row {
  list-style: none;
  margin: -2px 16px;
  display: block;
}
.liaison-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  background: transparent;
  border: 1px dashed var(--line);
  border-radius: 10px;
  padding: 6px 10px;
  color: var(--ink-soft);
  font-family: inherit;
  font-size: 0.78rem;
  text-align: left;
  cursor: pointer;
  transition: background 150ms ease, border-color 150ms ease, color 150ms ease;
}
.liaison-toggle:active { transform: scale(0.99); }
.liaison-icon {
  width: 22px; height: 22px;
  display: grid; place-items: center;
  border-radius: 50%;
  background: var(--bg-elev-2);
  color: var(--ink-soft);
  font-weight: 700;
  font-size: 0.85rem;
  flex-shrink: 0;
}
.liaison-body {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}
.liaison-title { font-weight: 600; color: var(--ink); }
.liaison-sub { font-size: 0.7rem; color: var(--ink-faint); }
.liaison-row.active .liaison-toggle {
  background: rgba(var(--green-rgb), 0.10);
  border-color: var(--green);
  border-style: solid;
  color: var(--ink);
}
.liaison-row.active .liaison-icon {
  background: var(--green);
  color: white;
}
.liaison-row.active .liaison-title { color: var(--green); }
@keyframes item-pop-in {
  0%   { transform: translateY(-8px) scale(0.96); background: rgba(var(--teal-rgb), 0.25); border-color: var(--teal); }
  60%  { transform: translateY(0) scale(1); background: rgba(var(--teal-rgb), 0.15); }
  100% { transform: translateY(0) scale(1); background: var(--bg-elev); border-color: var(--line); }
}
.routine-item.just-added { animation: item-pop-in 0.9s ease-out; }
.routine-item-index {
  width: 28px; height: 28px;
  display: grid; place-items: center;
  background: var(--bg-elev-2);
  color: var(--ink-soft);
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 600;
}
.routine-item-info { min-width: 0; }
.routine-item-code {
  font-size: 0.75rem;
  color: var(--teal);
  letter-spacing: 0.02em;
  font-weight: 600;
}
.routine-item-name {
  font-size: 0.95rem;
  line-height: 1.3;
  overflow-wrap: anywhere;
  word-break: normal;
  hyphens: auto;
}
.routine-item-tags {
  display: flex; gap: 4px;
  margin-top: 4px;
  font-size: 0.7rem;
  color: var(--ink-faint);
}
.routine-item-tags .tag {
  background: var(--bg-elev-2);
  padding: 1px 6px;
  border-radius: 4px;
}
.routine-item-tags .tag.sortie { color: var(--amber); }
.routine-item-tags .tag.ec { color: var(--green); }
.routine-item-letter {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--ink);
  letter-spacing: -0.02em;
  min-width: 24px;
  text-align: right;
}
.routine-item-letter.no-val { color: var(--amber); font-size: 1rem; }

.routine-empty {
  text-align: center;
  color: var(--ink-soft);
  padding: 28px 16px;
  margin: 0;
  background: var(--bg-elev);
  border: 1px dashed var(--line);
  border-radius: 12px;
  font-size: 0.95rem;
  line-height: 1.6;
}
.routine-empty strong { color: var(--teal); }

.primary-btn {
  width: 100%;
  margin-top: 16px;
  padding: 14px;
  background: var(--teal);
  color: #06181a;
  border-radius: 12px;
  font-weight: 700;
  font-size: 1rem;
  letter-spacing: -0.01em;
}
.primary-btn:active { background: var(--teal-deep); color: var(--ink); }

.share-btn {
  width: 100%;
  margin-top: 12px;
  padding: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--teal-deep);
  font-weight: 600;
  font-size: 1rem;
  box-shadow: var(--shadow-card);
}
.share-btn:active { background: var(--bg-elev-2); }

.celebration-share {
  grid-column: 1 / -1;
  padding: 11px;
  background: var(--green);
  color: var(--on-accent);
  border-radius: 10px;
  font-weight: 700;
  font-size: 0.95rem;
}
.celebration-share:active { filter: brightness(0.92); }

/* Advice box (Astuces / À vérifier) */
.advice-box {
  margin-top: 16px;
  display: grid;
  gap: 10px;
}
.advice-section {
  padding: 12px 14px 14px;
  border-radius: 12px;
  font-size: 0.92rem;
  line-height: 1.45;
}
.advice-section h4 {
  margin: 0 0 8px;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 700;
}
.advice-section ul {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 8px;
}
.advice-section li {
  position: relative;
  padding-left: 22px;
  color: var(--ink-soft);
}
.advice-section li::before {
  position: absolute;
  left: 0; top: 2px;
  width: 14px; height: 14px;
  display: grid; place-items: center;
  border-radius: 50%;
  font-size: 0.7rem;
  font-weight: 700;
  line-height: 1;
}
.advice-section strong { color: var(--ink); }
.advice-section.info {
  background: rgba(var(--teal-rgb), 0.08);
  border: 1px solid rgba(var(--teal-rgb), 0.3);
}
.advice-section.info h4 { color: var(--teal); }
.advice-section.info li::before {
  content: "+";
  background: rgba(var(--teal-rgb), 0.18);
  color: var(--teal);
}
.advice-section.warning {
  background: rgba(var(--amber-rgb), 0.07);
  border: 1px solid rgba(var(--amber-rgb), 0.3);
}
.advice-section.warning h4 { color: var(--amber); }
.advice-section.warning li::before {
  content: "!";
  background: rgba(var(--amber-rgb), 0.18);
  color: var(--amber);
}

/* Library */
.library-toolbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 14px;
  margin-bottom: 12px;
}
.filter-row {
  display: block;
  min-width: 0;
}
.filter-label {
  display: block;
  margin-bottom: 6px;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-faint);
  font-weight: 600;
  padding: 0 2px;
}
.search-row .filter-label {
  display: flex;
  align-items: center;
}
.search-wrap {
  position: relative;
  display: flex;
  align-items: center;
}
.search-icon {
  position: absolute;
  left: 14px;
  color: var(--teal);
  pointer-events: none;
}
.search-input {
  width: 100%;
  padding: 14px 42px 14px 42px;
  border-radius: 14px;
  background: var(--bg-elev);
  border: 2px solid var(--teal);
  color: var(--ink);
  font-size: 1.05rem;
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.04);
}
.search-input::placeholder {
  color: var(--ink-faint);
}
.search-input:focus {
  outline: none;
  border-color: var(--teal);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--teal) 25%, transparent);
}
.search-clear {
  position: absolute;
  right: 8px;
  width: 28px;
  height: 28px;
  border: none;
  background: var(--line);
  color: var(--ink);
  border-radius: 50%;
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.search-clear:hover {
  background: color-mix(in srgb, var(--ink-faint) 30%, var(--line));
}
.filter-chips {
  display: flex; gap: 6px;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
  padding-bottom: 2px;
  width: 100%;
  max-width: 100%;
  -webkit-overflow-scrolling: touch;
  scroll-behavior: smooth;
  flex-wrap: nowrap;
}
.filter-chips::-webkit-scrollbar { display: none; }
.chip {
  white-space: nowrap;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  color: var(--ink-soft);
  font-size: 0.85rem;
  font-weight: 500;
  flex-shrink: 0;
}
.chip.active {
  background: var(--teal);
  color: #06181a;
  border-color: var(--teal);
  font-weight: 600;
}
.library-count {
  margin: 4px 4px 8px;
  color: var(--ink-faint);
  font-size: 0.85rem;
}
.element-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; }
.element-card {
  display: grid;
  grid-template-columns: auto auto 1fr auto;
  align-items: center;
  gap: 10px;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  box-shadow: var(--shadow-card);
  width: 100%;
  text-align: left;
}
.element-card:active { background: var(--bg-elev-2); }
.element-letter {
  width: 44px; height: 44px;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  background: var(--bg-elev-2);
  border-radius: 10px;
  color: var(--teal);
  line-height: 1;
}
.element-letter .letter-l {
  font-size: 1.15rem;
  font-weight: 700;
}
.element-letter .letter-v {
  font-size: 0.6rem;
  margin-top: 3px;
  color: var(--ink-faint);
  font-weight: 500;
}
.element-letter.no-val { color: var(--amber); }
.element-letter.no-val .letter-v { font-size: 1rem; font-weight: 700; color: var(--amber); margin-top: 0; }
.element-letter.no-val .letter-l { font-size: 0.6rem; color: var(--ink-faint); margin-top: 2px; }
.element-info { min-width: 0; }
.element-meta {
  font-size: 0.7rem;
  color: var(--ink-faint);
  display: flex; gap: 6px; align-items: baseline;
  flex-wrap: wrap;
}
.element-meta .code { color: var(--teal); font-weight: 600; }
.element-meta .eponym { color: var(--amber); font-style: italic; }
.element-name {
  font-size: 0.95rem;
  line-height: 1.3;
  overflow-wrap: anywhere;
  word-break: normal;
  hyphens: auto;
}
.element-sub {
  font-size: 0.72rem;
  line-height: 1.3;
  color: var(--ink-faint);
  margin-top: 2px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  overflow-wrap: anywhere;
}
.element-meta .group { color: var(--ink-soft); }
.element-card.is-added { opacity: 0.65; }
.picto { display: block; width: 100%; height: 100%; }
.element-picto {
  width: 40px; height: 40px;
  padding: 5px;
  background: var(--bg-elev-2);
  border-radius: 10px;
  color: var(--ink-soft);
  flex: none;
}
.routine-item-picto {
  width: 34px; height: 34px;
  padding: 2px;
  color: var(--ink-soft);
}
.modal-picto {
  width: 72px; height: 72px;
  margin: 0 auto 10px;
  padding: 10px;
  background: var(--bg-elev-2);
  border-radius: 16px;
  color: var(--teal);
}

.liaison-row.serie .liaison-toggle { border-style: dashed; }
.ec-toggle-auto {
  margin-left: auto;
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--teal);
  white-space: nowrap;
}
.ec-toggle.auto { opacity: 0.9; }

.install-card {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  margin-top: 20px;
  padding: 14px;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow-card);
}
.install-card-icon { border-radius: 12px; flex: none; }
.install-card-body { min-width: 0; }
.install-card-title { font-weight: 700; font-size: 0.95rem; }
.install-card-text {
  margin: 4px 0 0;
  font-size: 0.8rem;
  line-height: 1.4;
  color: var(--ink-soft);
}
.install-card-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-top: 10px;
}
.install-btn {
  background: var(--teal);
  color: white;
  border: none;
  border-radius: 10px;
  padding: 8px 18px;
  font-size: 0.85rem;
  font-weight: 700;
}
.install-btn:active { opacity: 0.85; }
.install-later {
  background: none;
  border: none;
  color: var(--ink-faint);
  font-size: 0.8rem;
  padding: 8px 6px;
}
.element-added-badge {
  display: inline-block;
  margin-top: 4px;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--green);
  background: rgba(var(--green-rgb), 0.12);
  border: 1px solid rgba(var(--green-rgb), 0.35);
  border-radius: 6px;
  padding: 1px 6px;
}
.element-add {
  width: 36px; height: 36px;
  display: grid; place-items: center;
  background: var(--teal);
  color: #06181a;
  border-radius: 10px;
  font-size: 1.4rem;
  font-weight: 700;
}
.element-add.added {
  background: rgba(var(--green-rgb), 0.18);
  color: var(--green);
  font-size: 1.1rem;
}

.element-empty {
  list-style: none;
  text-align: center;
  padding: 32px 16px;
  background: var(--bg-elev);
  border: 1px dashed var(--line);
  border-radius: 12px;
  color: var(--ink-soft);
}
.element-empty-icon {
  font-size: 1.8rem;
  color: var(--ink-faint);
  margin-bottom: 4px;
}
.element-empty-title {
  font-size: 0.95rem;
  color: var(--ink);
  font-weight: 600;
  margin-bottom: 4px;
}
.element-empty-hint {
  font-size: 0.85rem;
  color: var(--ink-soft);
}
.element-approx-note {
  list-style: none;
  font-size: 0.85rem;
  color: var(--ink-soft);
  background: var(--bg-elev);
  border: 1px dashed var(--line);
  border-radius: 12px;
  padding: 10px 14px;
  margin-bottom: 10px;
}
.element-empty-advanced {
  margin-top: 12px;
  background: var(--teal);
  color: #06181a;
  border-color: var(--teal);
  font-weight: 600;
}

/* Dictée de routine */
.dictee-open-btn {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%;
  margin-top: 8px;
  padding: 12px;
  border-radius: 12px;
  background: var(--bg-elev);
  border: 1px dashed var(--teal);
  color: var(--teal);
  font-size: 0.95rem;
  font-weight: 600;
}
.dictee {
  position: fixed; inset: 0;
  z-index: 1000;
  background: linear-gradient(160deg, #fef9f0 0%, #fbf6ee 50%, #f5ede0 100%);
  display: flex; flex-direction: column;
  padding: calc(env(safe-area-inset-top, 0px) + 16px) 16px calc(env(safe-area-inset-bottom, 0px) + 16px);
  overflow-y: auto;
  animation: onb-fade 0.25s ease;
}
.dictee-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 4px;
}
.dictee-title { font-size: 1.25rem; margin: 0; }
.dictee-close {
  font-size: 1.6rem; line-height: 1;
  width: 40px; height: 40px;
  border-radius: 50%;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  color: var(--ink-soft);
}
.dictee-hint { color: var(--ink-soft); font-size: 0.9rem; margin: 4px 0 12px; }
.dictee-text {
  width: 100%;
  padding: 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #fff;
  font: inherit;
  font-size: 1rem;
  resize: vertical;
}
.dictee-actions {
  display: flex; gap: 10px;
  margin: 12px 0 16px;
}
.dictee-mic {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  flex: 1;
  padding: 12px;
  border-radius: 12px;
  background: var(--bg-elev);
  border: 1px solid var(--teal);
  color: var(--teal);
  font-size: 0.95rem;
  font-weight: 600;
}
.dictee-mic.listening {
  background: var(--teal);
  color: #06181a;
  animation: dictee-pulse 1.2s ease infinite;
}
@keyframes dictee-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(13, 184, 156, 0.4); }
  50% { box-shadow: 0 0 0 10px rgba(13, 184, 156, 0); }
}
.dictee-analyze { flex: 1; margin: 0; }
.dictee-results { display: grid; gap: 14px; }
.dictee-segment {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
}
.dictee-seg-label {
  font-weight: 700;
  font-size: 0.95rem;
  margin-bottom: 8px;
}
.dictee-cands { display: grid; gap: 6px; }
.dictee-cand {
  display: flex; align-items: center; gap: 10px;
  text-align: left;
  padding: 8px 10px;
  border-radius: 10px;
  background: #fff;
  border: 1.5px solid var(--line);
  font-size: 0.9rem;
}
.dictee-cand.selected {
  border-color: var(--teal);
  background: rgba(13, 184, 156, 0.08);
  font-weight: 600;
}
.dictee-cand-letter {
  flex-shrink: 0;
  min-width: 34px;
  text-align: center;
  font-weight: 700;
  color: var(--teal);
}
.dictee-cand-picto { flex-shrink: 0; width: 30px; height: 30px; }
.dictee-cand-picto svg { width: 30px; height: 30px; }
.dictee-cand-name { flex: 1; }
.dictee-skip { color: var(--ink-faint); justify-content: center; }
.dictee-skip.selected { border-color: var(--ink-faint); background: var(--bg-elev); }
.dictee-add { margin-top: 16px; }

/* Tab bar */
.tab-bar {
  position: fixed; bottom: 0; left: 0; right: 0;
  height: calc(var(--tab-h) + var(--safe-bot));
  padding-bottom: var(--safe-bot);
  background: rgba(251, 246, 238, 0.92);
  backdrop-filter: saturate(180%) blur(16px);
  border-top: 1px solid var(--line);
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  z-index: 20;
}
.tab {
  position: relative;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 2px;
  color: var(--ink-faint);
  font-size: 0.7rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  padding: 8px 4px;
}
.tab-dot {
  position: absolute;
  top: 10px;
  right: calc(50% - 22px);
  width: 9px; height: 9px;
  border-radius: 50%;
  background: var(--teal);
  box-shadow: 0 0 0 0 rgba(var(--teal-rgb), 0.6);
  animation: tab-dot-pulse 1.8s ease-out infinite;
  pointer-events: none;
}
@keyframes tab-dot-pulse {
  0%   { box-shadow: 0 0 0 0 rgba(var(--teal-rgb), 0.55); }
  70%  { box-shadow: 0 0 0 10px rgba(var(--teal-rgb), 0); }
  100% { box-shadow: 0 0 0 0 rgba(var(--teal-rgb), 0); }
}
.tab[disabled] { opacity: 0.4; }
.tab.active { color: var(--teal); }
.tab:not([disabled]):active { background: var(--bg-elev); }

/* Modal */
.modal {
  position: fixed; inset: 0; z-index: 100;
  display: flex; align-items: flex-end;
}
.modal-backdrop {
  position: absolute; inset: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(2px);
}
.modal-sheet {
  position: relative;
  width: 100%; max-height: 80dvh;
  background: var(--bg-elev);
  border-top-left-radius: 18px;
  border-top-right-radius: 18px;
  border: 1px solid var(--line);
  border-bottom: none;
  overflow: auto;
  animation: slide-up 0.25s ease;
}
@keyframes slide-up {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}
.modal-header {
  position: sticky; top: 0;
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px;
  background: var(--bg-elev);
  border-bottom: 1px solid var(--line);
}
.modal-header h3 { margin: 0; font-size: 1.1rem; }
.modal-close {
  width: 36px; height: 36px;
  border-radius: 10px;
  font-size: 1.6rem;
  color: var(--ink-soft);
  display: grid; place-items: center;
}
.modal-close:active { background: var(--bg-elev-2); }
.modal-body { padding: 16px; }
.modal-body p { color: var(--ink-soft); margin: 0 0 12px; }
.modal-body h4 {
  margin: 16px 0 6px;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--teal);
}
.modal-body ul { margin: 0 0 12px; padding-left: 18px; color: var(--ink-soft); }
.modal-body ul li + li { margin-top: 4px; }
.modal-body .note {
  font-size: 0.85rem;
  color: var(--ink-faint);
  font-style: italic;
}
.modal-body .hl-green { color: var(--green); font-weight: 600; }
.modal-body .hl-rose { color: var(--rose); font-weight: 600; }
.modal-intro {
  font-size: 0.95rem;
  color: var(--ink) !important;
  margin: 0 0 14px !important;
}
.modal-section-title {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-faint);
  font-weight: 600;
  margin: 14px 0 8px;
}
.modal-note {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  background: rgba(var(--amber-rgb), 0.10);
  border: 1px solid rgba(var(--amber-rgb), 0.35);
  border-radius: 10px;
  padding: 10px 12px;
  margin: 0 0 14px;
  font-size: 0.85rem;
  color: var(--ink);
}
.modal-note-icon {
  color: var(--amber);
  font-weight: 700;
  flex-shrink: 0;
}
.ec-toggle-list {
  display: grid;
  gap: 8px;
  margin: 4px 0;
}
.action-btn.ec-toggle {
  flex: none;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 10px;
  align-items: center;
  text-align: left;
  padding: 10px 12px;
}
.ec-toggle-id {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 2px 6px;
  border-radius: 6px;
  background: var(--bg-elev);
  color: var(--ink-soft);
}
.action-btn.ec-toggle.active .ec-toggle-id {
  background: rgba(6, 24, 26, 0.2);
  color: #06181a;
}
.ec-toggle-label {
  font-size: 0.88rem;
  font-weight: 500;
  line-height: 1.3;
}

/* Action sheet (élément contextuel) */
.action-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin: 12px 0 6px;
}
.action-btn {
  flex: 1 1 calc(50% - 3px);
  padding: 10px;
  border-radius: 10px;
  background: var(--bg-elev-2);
  color: var(--ink);
  font-size: 0.85rem;
  font-weight: 600;
  text-align: center;
}
.action-btn.active { background: var(--teal); color: #06181a; }
.action-btn.danger { color: var(--rose); }
.action-btn.danger.active { background: var(--rose); color: #06181a; }

/* Content / Apprendre */
.content-section-list { list-style: none; padding: 0; margin: 8px 0 0; display: grid; gap: 10px; }
.content-section-card {
  width: 100%;
  display: grid;
  grid-template-columns: 40px 1fr 18px;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 14px;
  color: var(--ink);
  text-align: left;
}
.content-section-card:active { background: var(--bg-elev-2); }
.content-section-icon {
  width: 40px; height: 40px;
  border-radius: 12px;
  background: rgba(var(--teal-rgb), 0.12);
  border: 1px solid rgba(var(--teal-rgb), 0.3);
  display: grid; place-items: center;
  color: var(--teal);
  font-weight: 700;
}
.content-section-icon[data-icon="play"]::before { content: "▶"; font-size: 0.9rem; }
.content-section-icon[data-icon="book"]::before { content: "Aa"; font-size: 0.85rem; }
.content-section-icon[data-icon="warn"]::before { content: "!"; font-size: 1.2rem; color: var(--amber); }
.content-section-icon[data-icon="rules"]::before { content: "\00A7"; font-size: 1.1rem; }
.content-section-title { font-weight: 600; font-size: 1rem; }
.content-section-arrow { color: var(--ink-faint); font-size: 1.4rem; line-height: 1; }

.content-intro {
  background: rgba(var(--teal-rgb), 0.08);
  border-left: 3px solid var(--teal);
  padding: 12px 14px;
  border-radius: 0 8px 8px 0;
  color: var(--ink);
  margin-bottom: 16px;
}
.content-step {
  display: grid;
  grid-template-columns: 32px 1fr;
  gap: 14px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}
.content-step:last-child { border-bottom: none; }
.content-step-n {
  width: 32px; height: 32px;
  background: var(--teal);
  color: #06181a;
  border-radius: 10px;
  font-weight: 700;
  display: grid; place-items: center;
  font-size: 1rem;
}
.content-step-body h4 { margin: 4px 0 4px; font-size: 1rem; font-weight: 600; }
.content-step-body p { margin: 0; color: var(--ink-soft); font-size: 0.92rem; }

.content-term {
  display: grid;
  grid-template-columns: 80px 1fr;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}
.content-term:last-child { border-bottom: none; }
.content-term-name {
  font-weight: 700;
  color: var(--teal);
  font-size: 0.95rem;
}
.content-term-def {
  color: var(--ink-soft);
  font-size: 0.9rem;
}

.content-trap {
  margin-bottom: 12px;
  padding: 12px 14px;
  background: rgba(var(--amber-rgb), 0.06);
  border: 1px solid rgba(var(--amber-rgb), 0.25);
  border-radius: 12px;
}
.content-trap-head {
  display: flex; justify-content: space-between; align-items: baseline;
  gap: 8px;
  margin-bottom: 6px;
}
.content-trap-title { font-weight: 600; }
.content-trap-cost {
  font-size: 0.8rem;
  color: var(--rose);
  font-weight: 600;
  background: rgba(var(--rose-rgb), 0.12);
  padding: 2px 8px;
  border-radius: 6px;
  white-space: nowrap;
}
.content-trap p { margin: 0; color: var(--ink-soft); font-size: 0.9rem; }

.content-head {
  margin: 24px 0 6px;
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--ink);
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
}
.content-head:first-child { margin-top: 2px; }
.content-head-sub { font-size: 0.78rem; font-weight: 600; color: var(--ink-faint); }
.content-sub {
  margin: 14px 0 2px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--teal);
}
.content-note {
  margin: 18px 0 0;
  font-size: 0.8rem;
  color: var(--ink-faint);
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

/* Desktop adjustments */
@media (min-width: 720px) {
  main.screens { max-width: 720px; margin: 0 auto; padding: 24px 24px calc(var(--tab-h) + var(--safe-bot) + 32px); }
  .apparatus-grid { grid-template-columns: repeat(4, 1fr); }
  .apparatus-card { aspect-ratio: auto; min-height: 160px; }
  .tab-bar { max-width: 720px; left: 50%; transform: translateX(-50%); border-left: 1px solid var(--line); border-right: 1px solid var(--line); }
}

/* Toast de mise à jour PWA */
.update-toast {
  position: fixed;
  left: 12px; right: 12px;
  bottom: calc(var(--tab-h) + var(--safe-bot) + 12px);
  z-index: 600;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  max-width: 480px; margin: 0 auto;
  padding: 12px 16px;
  background: var(--ink);
  color: var(--bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card-hover);
  font-size: 14px;
  animation: toast-in 0.25s ease-out;
}
.update-toast button {
  flex-shrink: 0;
  padding: 8px 14px;
  border-radius: 10px;
  background: var(--teal);
  color: var(--on-accent);
  font-weight: 700; font-size: 14px;
}
@keyframes toast-in {
  from { transform: translateY(12px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

/* ─── Tunnel visuel (bibliothèque poutre + sol) ─── */
.funnel-home { margin: 4px 0 10px; }
.funnel-title {
  margin: 6px 4px 10px;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--ink);
}
.family-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.family-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 12px 6px 10px;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow-card);
  color: var(--ink);
}
.family-card:active { background: var(--bg-elev-2); }
.family-card .picto { width: 38px; height: 38px; color: var(--teal-deep); }
.family-label { font-size: 0.9rem; font-weight: 600; }
.family-count { font-size: 0.75rem; color: var(--ink-faint); }
.funnel-crumbs {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 4px 0 8px;
}
.funnel-current {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.95rem;
  color: var(--ink);
}
.funnel-current .picto { width: 26px; height: 26px; color: var(--teal-deep); }
.facet-rows { display: grid; gap: 6px; margin-bottom: 8px; }

/* ─── Pictos animés (flipbook 3 poses : préparation → phase clé → réception) ─── */
.picto-anim .fr { opacity: 0; }
.picto-anim .fr1 { animation: picto-frame 1.8s infinite; }
.picto-anim .fr2 { animation: picto-frame 1.8s infinite 0.6s; }
.picto-anim .fr3 { animation: picto-frame 1.8s infinite 1.2s; }
@keyframes picto-frame {
  0%, 33.3% { opacity: 1; }
  33.4%, 100% { opacity: 0; }
}
@media (prefers-reduced-motion: reduce) {
  /* Pas d'animation : on fige la pose clé (2e), la plus parlante. */
  .picto-anim .fr { animation: none !important; }
  .picto-anim .fr2 { opacity: 1; }
}
