/* Carnet d'entraînement : cahier Seyès, marge rouge. La marge porte les
   numéros de série et les dates ; tout le reste reste sobre. */

:root {
  --papier: #f6f7f4;
  --bureau: #e3e6e8;
  --graphite: #23262a;
  --mine: #6b7178;
  --seyes: #c9d8e8;
  --marge: #d2453b;

  --margin-x: 56px;   /* position de la ligne de marge */
  --row: 32px;        /* hauteur d'un carreau Seyès */
  --condensed: "Archivo", system-ui, sans-serif;
  color-scheme: light;
}

* { box-sizing: border-box; }

html { background: var(--bureau); }

body {
  margin: 0;
  color: var(--graphite);
  font-family: "Archivo", system-ui, -apple-system, sans-serif;
  font-size: 17px;
  line-height: 1.5;
  font-variation-settings: "wdth" 100;
}

/* La page : papier réglé, marge rouge verticale. */
.page {
  max-width: 600px;
  min-height: 100vh;
  margin: 0 auto;
  padding: 0 18px calc(96px + env(safe-area-inset-bottom)) calc(var(--margin-x) + 16px);
  background:
    linear-gradient(90deg, transparent calc(var(--margin-x) - 1px), var(--marge) calc(var(--margin-x) - 1px) calc(var(--margin-x) + 1px), transparent calc(var(--margin-x) + 1px)),
    repeating-linear-gradient(transparent 0 calc(var(--row) - 1px), var(--seyes) calc(var(--row) - 1px) var(--row)),
    var(--papier);
  position: relative;
}

.topbar {
  padding: 20px 0 8px;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}

.brand {
  font-family: var(--condensed);
  font-variation-settings: "wdth" 75;
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--mine);
  text-decoration: none;
}

/* Un bloc dont la première colonne s'écrit dans la marge. */
.ruled {
  display: grid;
  grid-template-columns: var(--margin-x) 1fr;
  margin-left: calc(-1 * (var(--margin-x) + 16px));
  column-gap: 16px;
  align-items: baseline;
}
.in-margin {
  text-align: right;
  padding-right: 10px;
  color: var(--marge);
  font-family: var(--condensed);
  font-variation-settings: "wdth" 70;
  font-weight: 700;
  font-size: 0.95rem;
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
}

h1, h2, .big {
  font-family: var(--condensed);
  font-weight: 800;
  line-height: 1.05;
  margin: 0;
}
h1 { font-size: 2rem; font-variation-settings: "wdth" 75; margin: 18px 0 20px; }
h2 { font-size: 1.3rem; font-variation-settings: "wdth" 80; margin: 0 0 4px; }
.big { font-size: 4.5rem; font-variation-settings: "wdth" 62; letter-spacing: -0.01em; }

p { margin: 0 0 12px; }
a { color: inherit; }
.muted { color: var(--mine); }
.small { font-size: 0.9rem; }

.figures {
  font-family: var(--condensed);
  font-variation-settings: "wdth" 80;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.objective { color: var(--marge); }

section { margin: 0 0 28px; }

/* ---------- Accueil ---------- */

.next { margin: 12px 0 36px; }
.next .eyebrowless { color: var(--mine); margin-bottom: 4px; }
.preview { list-style: none; margin: 14px 0 20px; padding: 0; }
.preview li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  min-height: var(--row);
  align-items: center;
}
.switch { margin-top: 12px; }
.switch a { margin-right: 14px; }

.history { list-style: none; padding: 0; margin: 0; }
.history a {
  text-decoration: none;
  display: grid;
  min-height: 48px;
  align-items: center;
}

/* ---------- Boutons et champs ---------- */

button, .button {
  appearance: none;
  font: inherit;
  cursor: pointer;
  text-decoration: none;
  border-radius: 6px;
  border: 2px solid var(--graphite);
  background: transparent;
  color: var(--graphite);
  padding: 10px 16px;
  min-height: 48px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
}
button.primary, .button.primary {
  background: var(--graphite);
  color: var(--papier);
}
button.wide, .button.wide { width: 100%; font-size: 1.1rem; }
button.link {
  border: 0;
  padding: 0 4px;
  min-height: 44px;
  background: none;
  text-decoration: underline;
  text-underline-offset: 3px;
  font-weight: 500;
}
button.link.danger { color: var(--marge); }
button:disabled { opacity: 0.5; }

:focus-visible {
  outline: 3px solid var(--marge);
  outline-offset: 2px;
}

label {
  display: block;
  font-size: 0.85rem;
  color: var(--mine);
  margin-top: 10px;
}

input, textarea {
  font: inherit;
  color: var(--graphite);
  background: transparent;
  border: 0;
  border-bottom: 2px solid var(--mine);
  border-radius: 0;
  padding: 6px 2px;
  width: 100%;
  min-height: 44px;
}
input:focus, textarea:focus { border-bottom-color: var(--graphite); outline: none; }
input:focus-visible, textarea:focus-visible { outline: none; border-bottom-color: var(--marge); }
textarea { min-height: 72px; resize: vertical; }
::placeholder { color: #a3a9b0; }

/* ---------- Saisie d'une séance ---------- */

.exercise { margin: 0 0 34px; }
.exercise header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
}
.exercise header > span { white-space: nowrap; }
.last { font-size: 0.92rem; color: var(--mine); margin: 4px 0 6px; }

.set-row {
  display: grid;
  grid-template-columns: 1fr auto 1fr 44px;
  gap: 8px;
  align-items: end;
}
.set-row input {
  font-family: var(--condensed);
  font-variation-settings: "wdth" 80;
  font-weight: 700;
  font-size: 1.6rem;
  font-variant-numeric: tabular-nums;
  text-align: center;
  min-height: 52px;
}
.set-row .times { color: var(--mine); padding-bottom: 12px; }
.set-row .unit-head { font-size: 0.8rem; color: var(--mine); text-align: center; }
.set-row button.link { min-height: 52px; color: var(--mine); text-decoration: none; font-size: 1.2rem; }

.exercise-actions { margin-top: 6px; display: flex; gap: 8px; flex-wrap: wrap; }

.savebar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 12px 18px calc(12px + env(safe-area-inset-bottom));
  background: linear-gradient(transparent, var(--papier) 35%);
}
.savebar > * { max-width: 564px; margin: 0 auto; display: flex; }

.error { color: var(--marge); font-weight: 600; }

@media (prefers-reduced-motion: no-preference) {
  .saved-flash { animation: flash 900ms ease-out; }
  @keyframes flash { from { background: rgba(210, 69, 59, 0.12); } to { background: transparent; } }
}
