/* Charte graphique commune (reprise du QG, voir /root/boite-a-outils/charte-graphique.md) — accent sarcelle pour Cheval */
:root {
  --bg: #f4f5fa; --card: #ffffff; --card-2: #f7f8fc; --text: #111827; --muted: #6b7280;
  --border: #e6e8f0; --accent: #0f766e; --accent-2: #14b8a6; --accent-soft: #e6f6f4; --on-accent: #fff;
  --ok: #15803d; --ok-soft: #dcfce7; --warn: #b45309; --warn-soft: #fef3c7; --bad: #dc2626; --bad-soft: #fee2e2;
  --shadow: 0 1px 2px rgba(17, 24, 39, .04), 0 4px 16px rgba(17, 24, 39, .06);
  --radius: 18px; --nav-h: 64px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0c0e14; --card: #151821; --card-2: #1a1e29; --text: #e8eaf2; --muted: #8d93a5;
    --border: #252a37; --accent: #2dd4bf; --accent-2: #5eead4; --accent-soft: #10302d; --on-accent: #0c0e14;
    --ok: #4ade80; --ok-soft: #12301d; --warn: #fbbf24; --warn-soft: #3a2a0c; --bad: #f87171; --bad-soft: #3b1515;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 20px rgba(0, 0, 0, .25);
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.45 "Plus Jakarta Sans", system-ui, -apple-system, sans-serif; }
a { color: var(--accent); }
h1, h2, h3 { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
main { max-width: 760px; margin: 0 auto; padding: 8px 16px calc(var(--nav-h) + 24px + env(safe-area-inset-bottom)); }
.muted { color: var(--muted); font-size: .85rem; }
[hidden] { display: none !important; }

/* en-tête */
.top { position: sticky; top: 0; z-index: 50; background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); border-bottom: 1px solid var(--border);
  padding-top: env(safe-area-inset-top); }
.top-in { max-width: 760px; margin: 0 auto; padding: 10px 16px; display: flex; align-items: center; gap: 10px; }
.top-in h1 { font-size: 1.15rem; letter-spacing: -.01em; margin-right: auto; display: flex; align-items: center; gap: 8px; }
.retour { border: 0; background: none; font-size: 1.4rem; padding: 0 6px 0 0; cursor: pointer; color: var(--accent); min-height: 34px; }

/* onglets en bas (téléphone d'abord) */
.nav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 60; display: grid; grid-template-columns: repeat(4, 1fr);
  background: color-mix(in srgb, var(--card) 92%, transparent); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--border); padding-bottom: env(safe-area-inset-bottom); }
.nav a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; height: var(--nav-h);
  text-decoration: none; color: var(--muted); font-size: .72rem; font-weight: 600; }
.nav a span { font-size: 1.35rem; line-height: 1; filter: grayscale(.6); opacity: .8; }
.nav a.on { color: var(--accent); }
.nav a.on span { filter: none; opacity: 1; }

/* cartes et listes */
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 20px 2px 10px; }
.section-head h2 { font-size: 1.05rem; letter-spacing: -.01em; }
.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; min-width: 0; }
.card + .card { margin-top: 12px; }
.liste { display: grid; gap: 8px; grid-template-columns: minmax(0, 1fr); }
.liste > * { min-width: 0; }
.ligne { display: flex; align-items: center; gap: 12px; padding: 12px 14px; background: var(--card); border: 1px solid var(--border);
  border-radius: 14px; text-decoration: none; color: var(--text); cursor: pointer; width: 100%; text-align: left; }
.ligne:active { background: var(--card-2); }
.ligne .grand { flex: 1; min-width: 0; }
.ligne .grand b { display: block; }
.ligne .grand .muted { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ligne .fleche { color: var(--muted); }
.note { font-weight: 800; font-variant-numeric: tabular-nums; color: var(--accent); white-space: nowrap; }
.vide { text-align: center; padding: 28px 16px; color: var(--muted); }

/* boutons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 8px 14px; border-radius: 10px; font-size: .88rem; font-weight: 600;
  text-decoration: none; border: 1px solid var(--border); background: var(--card-2); color: var(--text); cursor: pointer; min-height: 40px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn.danger { color: var(--bad); }
.btn.petit { min-height: 34px; padding: 5px 10px; font-size: .8rem; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.actions .primary { flex: 1; }

/* pastilles */
.pill { display: inline-flex; align-items: center; gap: 4px; padding: 3px 9px; border-radius: 999px; font-size: .74rem; font-weight: 700; white-space: nowrap; }
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.bad { background: var(--bad-soft); color: var(--bad); }
.pill.neutral { background: var(--card-2); color: var(--muted); border: 1px solid var(--border); }
.pill.accent { background: var(--accent-soft); color: var(--accent); }
.puces { display: flex; gap: 6px; overflow-x: auto; padding: 2px 0 6px; scrollbar-width: none; }
.puces button { flex: none; padding: 7px 14px; border-radius: 999px; border: 1px solid var(--border); background: var(--card);
  font-weight: 600; font-size: .85rem; cursor: pointer; min-height: 36px; }
.puces button.on { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }

/* formulaires */
.field { display: grid; gap: 4px; margin-top: 12px; }
.field label { font-size: .8rem; font-weight: 600; color: var(--muted); }
.field input, .field select, .field textarea { width: 100%; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--card-2); font-size: 16px; /* 16 px : évite le zoom automatique de l'iPhone */ }
.field textarea { min-height: 160px; resize: vertical; line-height: 1.5; }
.field input:focus, .field select:focus, .field textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.deux { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.deux .field { margin-top: 12px; }
.bascule { display: flex; gap: 6px; }
.bascule button { flex: 1; padding: 9px; border-radius: 10px; border: 1px solid var(--border); background: var(--card-2); font-weight: 600; cursor: pointer; }
.bascule button.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.notes10 { display: grid; grid-template-columns: repeat(11, 1fr); gap: 4px; }
.notes10 button { padding: 8px 0; border-radius: 8px; border: 1px solid var(--border); background: var(--card-2); font-weight: 700;
  font-size: .85rem; cursor: pointer; min-height: 36px; }
.notes10 button.on { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.err { margin: 10px 0 0; padding: 8px 10px; border-radius: 10px; background: var(--bad-soft); color: var(--bad); font-size: .85rem; font-weight: 600; }
.texte-long { white-space: pre-wrap; margin: 8px 0 0; line-height: 1.55; }

/* agenda */
.mois-tete { display: flex; align-items: center; gap: 8px; margin: 14px 2px 10px; }
.mois-tete h2 { flex: 1; text-align: center; font-size: 1.05rem; text-transform: capitalize; }
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 3px; }
.cal .jsem { text-align: center; font-size: .72rem; color: var(--muted); font-weight: 700; padding-bottom: 2px; }
.cal button { min-height: 62px; border-radius: 10px; border: 1px solid var(--border); background: var(--card); padding: 3px 2px;
  display: flex; flex-direction: column; align-items: stretch; gap: 1px; cursor: pointer; overflow: hidden; text-align: left; }
.cal button.hors { opacity: .4; }
.cal button.auj { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.cal button.sel { background: var(--accent-soft); border-color: var(--accent); }
.cal .num { font-size: .78rem; font-weight: 700; padding-left: 3px; }
.cal .nom { font-size: .62rem; line-height: 1.2; padding: 1px 3px; border-radius: 4px; background: var(--accent-soft); color: var(--accent);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 700; }
.cal .nom.prevue { background: transparent; border: 1px dashed var(--accent); }
.cal .nom.repos { background: var(--card-2); color: var(--muted); }
.cal .plus { font-size: .6rem; color: var(--muted); padding-left: 3px; }
.legende { display: flex; gap: 12px; justify-content: center; margin-top: 8px; font-size: .74rem; color: var(--muted); }
.legende i { display: inline-block; width: 18px; height: 10px; border-radius: 3px; vertical-align: -1px; margin-right: 4px; background: var(--accent-soft); }
.legende i.prevue { background: transparent; border: 1px dashed var(--accent); }

/* exercices */
.galerie { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.vignette { text-decoration: none; color: var(--text); display: block; background: var(--card); border: 1px solid var(--border); border-radius: 14px; overflow: hidden; cursor: pointer; padding: 0; text-align: left; }
.vignette .img { aspect-ratio: 5 / 7; background: #fff; display: grid; place-items: center; overflow: hidden; }
.vignette img { width: 100%; height: 100%; object-fit: contain; }
.vignette b { display: block; padding: 8px 10px; font-size: .85rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* zone de dessin (toujours sur fond blanc, même en mode sombre) */
.outils { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 10px 0; }
.outils button { min-width: 38px; min-height: 38px; border-radius: 10px; border: 1px solid var(--border); background: var(--card); cursor: pointer;
  font-size: 1rem; padding: 0 8px; font-weight: 600; }
.outils button.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.outils .sep { width: 1px; height: 28px; background: var(--border); margin: 0 2px; }
.couleur { width: 22px; height: 22px; border-radius: 50%; display: inline-block; vertical-align: middle; border: 2px solid rgba(0,0,0,.15); }
.toile { background: #fff; border: 1px solid var(--border); border-radius: 12px; overflow: hidden; touch-action: none; position: relative; }
.toile { display: flex; justify-content: center; }
/* la feuille tient entière dans l'écran (on ne peut pas faire défiler en touchant la feuille) */
.toile canvas { display: block; width: auto; height: auto; max-width: 100%;
  max-height: calc(100dvh - var(--nav-h) - env(safe-area-inset-bottom) - env(safe-area-inset-top) - 140px); touch-action: none; }

/* connexion */
body.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: min(100%, 360px); display: flex; flex-direction: column; gap: 12px; text-align: center; }
.login-card .logo { width: 72px; height: 72px; margin: 0 auto; display: grid; place-items: center; border-radius: 20px; font-size: 2.4rem;
  background: linear-gradient(135deg, var(--accent-2), var(--accent)); }
.login-card h1 { font-size: 1.3rem; }
.login-card input { padding: 12px; border-radius: 10px; border: 1px solid var(--border); background: var(--card-2); text-align: center; font-size: 16px; }
.login-card button { padding: 12px; border-radius: 10px; border: 0; background: var(--accent); color: var(--on-accent); font-weight: 700; cursor: pointer; }

/* message en bas */
.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--nav-h) + 16px + env(safe-area-inset-bottom)); z-index: 90;
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-weight: 600; font-size: .88rem; box-shadow: var(--shadow);
  max-width: calc(100% - 32px); }
.toast.bad { background: var(--bad); color: #fff; }
