:root {
  color-scheme: dark;
  --bg: #111318;
  --bg-elevated: #171a21;
  --panel: #1d222b;
  --panel-strong: #232936;
  --line: #333b48;
  --line-soft: rgba(255, 255, 255, 0.08);
  --text: #f4f7ee;
  --muted: #aab3c0;
  --subtle: #747f91;
  /* Accent pilotable : --accent est la seule couleur à changer, le reste en dérive.
     --accent-text est éclairci pour rester lisible en texte sur fond sombre,
     --accent-ink est l'encre posée SUR un aplat d'accent. */
  --accent: #7bf1a8;
  --accent-strong: #35d77d;
  --accent-text: #7bf1a8;
  --accent-ink: #0e1410;
  --accent-rgb: 123, 241, 168;
  --green: var(--accent);
  --green-strong: var(--accent-strong);
  --coral: #ff7a59;
  --blue: #69b7ff;
  --yellow: #ffd166;
  --danger: #ff5e6c;
  --shadow: 0 18px 60px rgba(0, 0, 0, 0.32);
  --radius: 8px;
  --font: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--bg);
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(180deg, rgba(var(--accent-rgb), 0.06), transparent 28rem),
    radial-gradient(circle at top right, rgba(105, 183, 255, 0.08), transparent 28rem),
    var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.45;
  letter-spacing: 0;
}

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

button {
  cursor: pointer;
}

a {
  color: inherit;
}

.app-shell {
  display: grid;
  grid-template-columns: 17.5rem minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  height: 100vh;
  padding: 1.25rem;
  background: rgba(17, 19, 24, 0.92);
  border-right: 1px solid var(--line-soft);
  backdrop-filter: blur(18px);
}

.brand {
  display: grid;
  grid-template-columns: 3.25rem 1fr;
  align-items: center;
  gap: 0.8rem;
  color: var(--text);
  text-decoration: none;
}

.brand-mark {
  width: 3.25rem;
  height: auto;
  object-fit: contain;
}

.brand strong,
.brand small {
  display: block;
}

.brand small,
.sidebar-card small,
.muted {
  color: var(--muted);
}

.nav-list {
  display: grid;
  gap: 0.45rem;
}

.nav-item,
.ghost-button,
.primary-button,
.icon-button {
  border: 1px solid transparent;
  border-radius: var(--radius);
  transition:
    transform 160ms ease,
    border-color 160ms ease,
    background 160ms ease,
    color 160ms ease;
}

.nav-item {
  width: 100%;
  padding: 0.78rem 0.9rem;
  background: transparent;
  color: var(--muted);
  text-align: left;
}

.nav-item:hover,
.nav-item.active {
  background: var(--panel);
  border-color: var(--line-soft);
  color: var(--text);
}

.nav-item.active {
  box-shadow: inset 3px 0 0 var(--green);
}

.sidebar-card,
.panel,
.stat-card,
.exercise-card,
.meal-card,
.timeline-item,
.source-card {
  background: rgba(29, 34, 43, 0.9);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
}

.sidebar-card {
  margin-top: auto;
  padding: 1rem;
}

.sidebar-card strong {
  display: block;
  margin: 0.35rem 0;
}

.main-area {
  min-width: 0;
  overflow-x: hidden;
  padding: 1.25rem clamp(1rem, 3vw, 2rem) 2.5rem;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin: -1.25rem calc(clamp(1rem, 3vw, 2rem) * -1) 1.4rem;
  padding: 1rem clamp(1rem, 3vw, 2rem);
  background: rgba(17, 19, 24, 0.82);
  border-bottom: 1px solid var(--line-soft);
  backdrop-filter: blur(18px);
}

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

h1 {
  margin-bottom: 0;
  font-size: clamp(1.55rem, 2.2vw, 2.4rem);
  line-height: 1.05;
}

h2 {
  margin-bottom: 1rem;
  font-size: 1.15rem;
}

h3 {
  margin-bottom: 0.45rem;
  font-size: 1rem;
}

.eyebrow {
  margin: 0 0 0.35rem;
  color: var(--accent-text);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.grid {
  display: grid;
  gap: 1rem;
}

.dashboard-grid {
  grid-template-columns: minmax(19rem, 0.95fr) minmax(0, 1.45fr);
  align-items: start;
}

.two-col {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.three-col {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.four-col {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.panel {
  min-width: 0;
  padding: 1rem;
  box-shadow: var(--shadow);
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

.panel-header p {
  margin-bottom: 0;
  color: var(--muted);
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.8rem;
}

.stat-card {
  padding: 0.9rem;
  min-height: 6rem;
}

.stat-card span {
  display: block;
  color: var(--subtle);
  font-size: 0.82rem;
  font-weight: 700;
}

.stat-card strong {
  display: block;
  margin: 0.35rem 0 0.25rem;
  font-size: clamp(1.35rem, 2.2vw, 2rem);
  line-height: 1;
}

.stat-card small {
  color: var(--muted);
}

.quick-form,
.compact-form {
  display: grid;
  gap: 0.8rem;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
}

.form-grid.wide {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.field {
  display: grid;
  gap: 0.35rem;
}

.field.full {
  grid-column: 1 / -1;
}

label,
.label {
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 700;
}

input,
select,
textarea {
  min-width: 0;
  width: 100%;
  min-height: 2.65rem;
  padding: 0.72rem 0.78rem;
  background: #101319;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--text);
  outline: none;
}

textarea {
  min-height: 5rem;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(var(--accent-rgb), 0.12);
}

.check-row {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  min-height: 2.65rem;
}

.check-row input {
  width: 1.1rem;
  min-height: 1.1rem;
  accent-color: var(--green);
}

.primary-button,
.ghost-button,
.danger-button {
  min-height: 2.65rem;
  padding: 0.72rem 0.95rem;
  font-weight: 800;
}

.primary-button {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: var(--accent);
}

.primary-button:hover {
  transform: translateY(-1px);
  background: var(--green-strong);
}

.ghost-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  background: rgba(255, 255, 255, 0.04);
  border-color: var(--line-soft);
  color: var(--text);
  text-decoration: none;
}

.ghost-button:hover {
  background: rgba(255, 255, 255, 0.08);
}

.danger-button {
  background: rgba(255, 94, 108, 0.14);
  border: 1px solid rgba(255, 94, 108, 0.38);
  border-radius: var(--radius);
  color: #ffd9dd;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.icon-button {
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 2.65rem;
  height: 2.65rem;
  padding: 0;
  background: rgba(255, 255, 255, 0.04);
  border-color: var(--line-soft);
  color: var(--text);
}

.icon-button:hover,
.icon-button.admin-unlocked {
  background: rgba(var(--accent-rgb), 0.12);
  border-color: rgba(var(--accent-rgb), 0.35);
  color: var(--accent-text);
}

.icon-button svg {
  width: 1.2rem;
  height: 1.2rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.file-button {
  position: relative;
  overflow: hidden;
}

.file-button input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.chart-wrap {
  position: relative;
  width: 100%;
  min-height: 18rem;
}

.chart-wrap canvas {
  display: block;
  width: 100%;
  height: 18rem;
}

.chart-wrap.large canvas {
  height: 24rem;
}

.tabs {
  display: flex;
  gap: 0.5rem;
  max-width: 100%;
  overflow-x: auto;
  padding-bottom: 0.35rem;
}

.tab-button {
  flex: 0 0 auto;
  min-height: 2.45rem;
  padding: 0.58rem 0.8rem;
  border: 1px solid var(--line-soft);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--muted);
  font-weight: 800;
}

.tab-button.active {
  background: var(--text);
  color: #101216;
}

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

.exercise-card {
  min-width: 0;
  display: grid;
  grid-template-rows: auto 1fr;
  overflow: hidden;
}

.exercise-media {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 18rem;
  background: #fff;
  overflow: hidden;
}

/* Les fichiers sources font 180x180 (limite imposée par la licence Gym visual).
   On les agrandit à l'affichage sans jamais redistribuer de résolution
   supérieure ; au-delà de ~17rem le rendu commence à ramollir. */
.exercise-media img {
  width: min(100%, 17rem);
  height: auto;
  aspect-ratio: 1;
  object-fit: contain;
}


.exercise-body {
  min-width: 0;
  display: grid;
  gap: 0.8rem;
  padding: 0.95rem;
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.chip {
  display: inline-flex;
  align-items: center;
  min-height: 1.65rem;
  padding: 0.25rem 0.5rem;
  border: 1px solid var(--line-soft);
  border-radius: 999px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.chip.green {
  background: rgba(var(--accent-rgb), 0.12);
  border-color: rgba(var(--accent-rgb), 0.22);
  color: var(--accent-text);
}

.chip.coral {
  background: rgba(255, 122, 89, 0.12);
  border-color: rgba(255, 122, 89, 0.22);
  color: var(--coral);
}

.set-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.45rem;
}

.set-grid input {
  padding-inline: 0.45rem;
  text-align: center;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 42rem;
}

th,
td {
  padding: 0.75rem;
  border-bottom: 1px solid var(--line-soft);
  text-align: left;
  vertical-align: top;
}

th {
  color: var(--muted);
  font-size: 0.82rem;
  text-transform: uppercase;
}

.meal-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr));
  gap: 0.8rem;
}

.meal-card {
  display: grid;
  gap: 0.6rem;
  padding: 0.9rem;
}

.meal-card strong {
  display: block;
}

.meal-card p {
  margin-bottom: 0;
  color: var(--muted);
}

.timeline {
  display: grid;
  gap: 0.75rem;
}

.timeline-item {
  display: grid;
  grid-template-columns: 8.5rem 1fr auto;
  gap: 1rem;
  padding: 0.95rem;
  align-items: center;
}

.timeline-item time {
  color: var(--accent-text);
  font-weight: 900;
}

.timeline-item p {
  margin-bottom: 0;
  color: var(--muted);
}

.photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(13rem, 1fr));
  gap: 0.8rem;
}

.photo-card {
  overflow: hidden;
  background: var(--panel);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
}

.photo-card img {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 5;
  object-fit: cover;
}

.photo-card div {
  padding: 0.75rem;
}

.source-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(18rem, 1fr));
  gap: 0.8rem;
}

.source-card {
  padding: 0.9rem;
}

.source-card p {
  margin-bottom: 0;
  color: var(--muted);
}

.admin-modal[hidden] {
  display: none;
}

.admin-modal {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 1rem;
}

.admin-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(5, 7, 10, 0.72);
  backdrop-filter: blur(10px);
}

.admin-dialog {
  position: relative;
  width: min(42rem, 100%);
  max-height: min(90vh, 48rem);
  overflow: auto;
  padding: 1rem;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.admin-dialog .panel-header {
  margin-bottom: 1.2rem;
}

.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.8rem;
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
}

.switch-row span {
  display: block;
}

.switch-row small {
  display: block;
  margin-top: 0.2rem;
  color: var(--muted);
}

.switch {
  position: relative;
  flex: 0 0 auto;
  width: 3.25rem;
  height: 1.75rem;
}

.switch input {
  position: absolute;
  inset: 0;
  width: 100%;
  min-height: 0;
  opacity: 0;
}

.switch i {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: #0f1218;
  border: 1px solid var(--line);
  border-radius: 999px;
  transition:
    background 160ms ease,
    border-color 160ms ease;
}

.switch i::after {
  content: "";
  position: absolute;
  top: 0.22rem;
  left: 0.24rem;
  width: 1.22rem;
  height: 1.22rem;
  background: var(--muted);
  border-radius: 50%;
  transition:
    transform 160ms ease,
    background 160ms ease;
}

.switch input:checked + i {
  background: rgba(var(--accent-rgb), 0.16);
  border-color: rgba(var(--accent-rgb), 0.45);
}

.switch input:checked + i::after {
  transform: translateX(1.45rem);
  background: var(--green);
}

.toast {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  z-index: 20;
  max-width: min(28rem, calc(100vw - 2rem));
  padding: 0.85rem 1rem;
  background: var(--text);
  border-radius: var(--radius);
  color: #101216;
  font-weight: 800;
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transform: translateY(0.7rem);
  transition:
    opacity 180ms ease,
    transform 180ms ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.empty {
  display: grid;
  place-items: center;
  min-height: 12rem;
  padding: 2rem;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  color: var(--muted);
  text-align: center;
}

.inline-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.stack {
  display: grid;
  gap: 1rem;
}

.metric-line {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  padding: 0.55rem 0;
  border-bottom: 1px solid var(--line-soft);
}

.metric-line:last-child {
  border-bottom: 0;
}

.metric-line span:first-child {
  color: var(--muted);
}

.metric-line strong {
  min-width: 0;
  text-align: right;
  overflow-wrap: anywhere;
}

@media (max-width: 1100px) {
  .dashboard-grid,
  .two-col,
  .three-col,
  .four-col,
  .stat-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 820px) {
  body {
    overflow-x: hidden;
  }

  .app-shell {
    display: block;
  }

  .sidebar {
    position: static;
    height: auto;
    padding: 0.9rem;
    border-right: 0;
    border-bottom: 1px solid var(--line-soft);
  }

  .brand {
    grid-template-columns: 2.5rem 1fr;
  }

  .brand-mark {
    width: 2.5rem;
    height: 2.5rem;
  }

  .nav-list {
    display: flex;
    overflow-x: auto;
    padding-bottom: 0.2rem;
  }

  .nav-item {
    flex: 0 0 auto;
    width: auto;
    white-space: nowrap;
  }

  .sidebar-card {
    display: none;
  }

  .topbar {
    position: static;
    align-items: flex-start;
    flex-direction: column;
    margin-top: 0;
  }

  .dashboard-grid,
  .two-col,
  .three-col,
  .four-col,
  .stat-grid,
  .form-grid,
  .form-grid.wide,
  .timeline-item {
    grid-template-columns: 1fr;
  }

  .metric-line strong {
    text-align: left;
  }

  .exercise-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .set-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 1ms !important;
    scroll-behavior: auto !important;
    transition-duration: 1ms !important;
  }
}

/* ---- Sélecteur de couleur du thème ---- */
.theme-picker {
  position: relative;
  flex: none;
}

.theme-panel {
  position: absolute;
  right: 0;
  top: calc(100% + 0.5rem);
  z-index: 30;
  display: grid;
  gap: 0.7rem;
  width: 15.5rem;
  padding: 0.9rem;
  background: var(--panel-strong);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.theme-panel[hidden] {
  display: none;
}

.theme-panel .eyebrow {
  margin: 0;
}

.theme-swatches {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 0.4rem;
}

.theme-swatch {
  position: relative;
  aspect-ratio: 1;
  padding: 0;
  border: 1px solid var(--line-soft);
  border-radius: 6px;
  background: var(--swatch);
  cursor: pointer;
  transition:
    transform 140ms ease,
    box-shadow 140ms ease;
}

.theme-swatch:hover {
  transform: translateY(-1px);
}

.theme-swatch.active {
  box-shadow:
    0 0 0 2px var(--panel-strong),
    0 0 0 4px var(--swatch);
}

.theme-custom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  color: var(--muted);
  font-size: 0.85rem;
}

.theme-custom input[type="color"] {
  width: 2.75rem;
  height: 2rem;
  padding: 0;
  background: none;
  border: 1px solid var(--line);
  border-radius: 6px;
  cursor: pointer;
}

.theme-custom input[type="color"]::-webkit-color-swatch-wrapper {
  padding: 2px;
}

.theme-custom input[type="color"]::-webkit-color-swatch {
  border: none;
  border-radius: 4px;
}

.theme-preview {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem;
  background: var(--bg);
  border: 1px solid var(--line-soft);
  border-radius: 6px;
}

.theme-preview .primary-button {
  min-height: 2.1rem;
  padding: 0.35rem 0.7rem;
  font-size: 0.82rem;
}

.theme-reset {
  min-height: 2.2rem;
  font-size: 0.82rem;
}

@media (max-width: 720px) {
  .theme-panel {
    position: fixed;
    right: 1rem;
    left: 1rem;
    top: auto;
    bottom: 1rem;
    width: auto;
  }
}

/* ---- Mention d'attribution et bouton info sur la vignette ---- */

.info-button {
  position: absolute;
  right: 0.5rem;
  bottom: 0.5rem;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  gap: 0.32rem;
  padding: 0.28rem 0.45rem;
  background: rgba(17, 19, 24, 0.86);
  border: 1px solid var(--line-soft);
  border-radius: 5px;
  color: var(--text);
  font-size: 0.74rem;
  text-decoration: none;
  transition:
    background 160ms ease,
    border-color 160ms ease;
}

.info-button:hover {
  background: rgba(17, 19, 24, 0.96);
  border-color: rgba(var(--accent-rgb), 0.5);
  color: var(--accent-text);
}

.info-button svg {
  width: 0.95rem;
  height: 0.95rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
}

/* ---- Bande de récupération en pied de carte ---- */
.rest-strip {
  margin: 0 0 0.6rem;
}

.rest-start {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  width: 100%;
  min-height: 2.35rem;
  padding: 0.4rem 0.7rem;
  background: rgba(var(--accent-rgb), 0.08);
  border: 1px dashed rgba(var(--accent-rgb), 0.4);
  border-radius: var(--radius);
  color: var(--accent-text);
  font-size: 0.82rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  transition:
    background 160ms ease,
    border-color 160ms ease;
}

.rest-start:hover {
  background: rgba(var(--accent-rgb), 0.16);
  border-style: solid;
}

.rest-start svg {
  width: 1rem;
  height: 1rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
}

/* ---- Minuteur flottant ---- */
.rest-timer {
  position: fixed;
  left: 1rem;
  bottom: 1rem;
  z-index: 25;
  display: grid;
  gap: 0.6rem;
  width: min(17rem, calc(100vw - 2rem));
  padding: 0.9rem;
  background: var(--panel-strong);
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.rest-timer[hidden] {
  display: none;
}

.rest-timer-head .eyebrow {
  margin: 0 0 0.15rem;
}

.rest-timer-head strong {
  display: block;
  font-size: 1.85rem;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}

.rest-timer-head small {
  color: var(--muted);
}

.rest-timer-bar {
  height: 0.3rem;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 999px;
  overflow: hidden;
}

.rest-timer-bar i {
  display: block;
  width: 0;
  height: 100%;
  background: var(--accent);
  transition: width 900ms linear;
}

.rest-timer-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.45rem;
}

.rest-timer-actions .ghost-button {
  min-height: 2.2rem;
  font-size: 0.82rem;
}

/* ---- Fiche technique ---- */
.guide-modal {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 1rem;
}

.guide-modal[hidden] {
  display: none;
}

.guide-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(8, 9, 12, 0.72);
  backdrop-filter: blur(3px);
}

.guide-panel {
  position: relative;
  z-index: 1;
  display: grid;
  gap: 0.9rem;
  width: min(44rem, 100%);
  max-height: min(85vh, 46rem);
  overflow-y: auto;
  padding: 1.2rem;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.guide-body {
  display: grid;
  grid-template-columns: 11.25rem minmax(0, 1fr);
  gap: 1.1rem;
  align-items: start;
}

.guide-media {
  width: 11.25rem;
  height: 11.25rem;
  object-fit: contain;
  background: #fff;
  border-radius: var(--radius);
}

.guide-steps {
  margin: 0;
  padding-left: 1.2rem;
  display: grid;
  gap: 0.55rem;
}

.guide-steps li {
  padding-left: 0.15rem;
  line-height: 1.5;
}

.guide-steps li::marker {
  color: var(--accent-text);
  font-weight: 900;
}

.guide-meta {
  margin: 0;
}

.guide-credit {
  margin: 0;
  color: var(--subtle);
  font-size: 0.76rem;
}

body.modal-open {
  overflow: hidden;
}

@media (max-width: 720px) {
  .guide-body {
    grid-template-columns: minmax(0, 1fr);
    justify-items: center;
  }

  .rest-timer {
    left: 1rem;
    right: 1rem;
    width: auto;
  }
}

/* ---- Planificateur de la semaine ---- */
.planner-hint {
  margin: 0 0 0.9rem;
  font-size: 0.86rem;
}

.planner-layout {
  display: grid;
  grid-template-columns: 16rem minmax(0, 1fr);
  gap: 1rem;
  align-items: start;
}

.food-panel {
  position: sticky;
  top: 1rem;
  display: grid;
  gap: 0.6rem;
  padding: 0.8rem;
  background: var(--bg-elevated);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
}

.food-cats {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
}

.cat-chip {
  cursor: pointer;
  border: 1px solid var(--line);
  background: transparent;
  transition:
    background 140ms ease,
    border-color 140ms ease;
}

.cat-chip.active {
  background: rgba(var(--accent-rgb), 0.14);
  border-color: rgba(var(--accent-rgb), 0.45);
  color: var(--accent-text);
}

.food-list {
  display: grid;
  gap: 0.35rem;
  max-height: 32rem;
  overflow-y: auto;
  padding-right: 0.2rem;
}

.food-item {
  display: grid;
  gap: 0.1rem;
  padding: 0.5rem 0.6rem;
  background: var(--panel);
  border: 1px solid var(--line-soft);
  border-radius: 6px;
  color: var(--text);
  text-align: left;
  cursor: grab;
  transition:
    border-color 140ms ease,
    transform 140ms ease;
}

.food-item:hover {
  transform: translateY(-1px);
  border-color: rgba(var(--accent-rgb), 0.5);
}

.food-item.dragging {
  opacity: 0.45;
  cursor: grabbing;
}

.food-name {
  font-weight: 800;
  font-size: 0.88rem;
}

.food-portion {
  color: var(--muted);
  font-size: 0.75rem;
}

.food-macros {
  color: var(--subtle);
  font-size: 0.72rem;
  font-variant-numeric: tabular-nums;
}

.planner-main {
  display: grid;
  gap: 0.9rem;
  min-width: 0;
}

.planner-grid {
  display: grid;
  gap: 0.4rem;
  min-width: 0;
  overflow-x: auto;
}

.planner-row {
  display: grid;
  grid-template-columns: 8.5rem repeat(4, minmax(8rem, 1fr)) 7.5rem;
  gap: 0.4rem;
  align-items: stretch;
}

.planner-head {
  position: sticky;
  top: 0;
  z-index: 1;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.planner-head > div {
  padding: 0.3rem 0.5rem;
}

.planner-day {
  display: grid;
  gap: 0.25rem;
  align-content: center;
  padding: 0.5rem;
  background: var(--bg-elevated);
  border: 1px solid var(--line-soft);
  border-radius: 6px;
}

.planner-day .chip {
  justify-self: start;
  font-size: 0.68rem;
}

.planner-cell {
  display: flex;
  flex-wrap: wrap;
  align-content: flex-start;
  gap: 0.25rem;
  min-height: 4.2rem;
  padding: 0.4rem;
  background: var(--panel);
  border: 1px dashed var(--line);
  border-radius: 6px;
  cursor: pointer;
  transition:
    border-color 140ms ease,
    background 140ms ease;
}

.planner-cell:hover {
  border-color: rgba(var(--accent-rgb), 0.45);
}

.planner-cell.active {
  border-style: solid;
  border-color: var(--accent);
  background: rgba(var(--accent-rgb), 0.06);
}

.planner-cell.over {
  border-style: solid;
  border-color: var(--accent);
  background: rgba(var(--accent-rgb), 0.16);
}

.cell-hint {
  align-self: center;
  margin: auto;
  color: var(--subtle);
  font-size: 1.1rem;
}

.plan-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.28rem;
  padding: 0.2rem 0.4rem;
  background: rgba(var(--accent-rgb), 0.12);
  border: 1px solid rgba(var(--accent-rgb), 0.28);
  border-radius: 999px;
  color: var(--accent-text);
  font-size: 0.72rem;
  font-weight: 700;
  cursor: pointer;
}

.plan-chip i {
  font-style: normal;
  opacity: 0.6;
}

.plan-chip:hover {
  background: rgba(var(--danger-rgb, 255, 94, 108), 0.16);
  border-color: var(--danger);
  color: var(--danger);
}

.planner-total {
  display: grid;
  align-content: center;
  gap: 0.05rem;
  padding: 0.4rem 0.5rem;
  background: var(--bg-elevated);
  border: 1px solid var(--line-soft);
  border-left: 3px solid var(--line);
  border-radius: 6px;
  text-align: right;
}

.planner-total strong {
  font-size: 1.15rem;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}

.planner-total small,
.planner-total span {
  color: var(--muted);
  font-size: 0.72rem;
}

.planner-total em {
  color: var(--coral);
  font-size: 0.68rem;
  font-style: normal;
  font-weight: 700;
}

.planner-total.ok {
  border-left-color: var(--accent);
}

.planner-total.bas {
  border-left-color: var(--blue);
}

.planner-total.haut {
  border-left-color: var(--coral);
}

.planner-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr));
  gap: 0.5rem;
  padding: 0.8rem;
  background: var(--bg-elevated);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
}

.planner-verdict {
  grid-column: 1 / -1;
  margin: 0;
  padding-top: 0.4rem;
  border-top: 1px solid var(--line-soft);
  font-size: 0.86rem;
}

@media (max-width: 1100px) {
  .planner-layout {
    grid-template-columns: minmax(0, 1fr);
  }

  .food-panel {
    position: static;
  }

  .food-list {
    max-height: 18rem;
    grid-template-columns: repeat(auto-fill, minmax(11rem, 1fr));
  }

  .planner-grid {
    overflow-x: auto;
  }

  .planner-row {
    grid-template-columns: 7rem repeat(4, minmax(7.5rem, 1fr)) 6.5rem;
    min-width: 44rem;
  }
}

/* Le résumé empile libellé et valeur : .metric-line est prévu pour du pleine largeur. */
.planner-summary .metric-line {
  display: grid;
  gap: 0.1rem;
  padding: 0.55rem 0.7rem;
  background: var(--panel);
  border: 1px solid var(--line-soft);
  border-radius: 6px;
}

.planner-summary .metric-line span:first-child {
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.planner-summary .metric-line strong {
  font-size: 1.05rem;
  font-variant-numeric: tabular-nums;
}
