:root {
  --bg: #f6f4ef;
  --surface: #ffffff;
  --ink: #111418;
  --ink-2: #4a5059;
  --ink-3: #7b818a;
  --line: #e4e0d7;
  --accent: #ffb020;
  --accent-ink: #111418;
  --danger: #c2352b;
  --ok: #1f7a4d;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(17, 20, 24, .06), 0 4px 16px rgba(17, 20, 24, .05);
  --font: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --display: "Bebas Neue", "Inter", sans-serif;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
  min-height: 100dvh;
}

a { color: inherit; }
h1, h2, h3 { margin: 0; line-height: 1.15; }
h1 { font-family: var(--display); font-weight: 400; font-size: 2.4rem; letter-spacing: .01em; }
h2 { font-size: 1.05rem; font-weight: 650; }
p { margin: 0; }
.muted { color: var(--ink-2); }
.small { font-size: .875rem; }

/* Mise en page */
.shell { max-width: 560px; margin: 0 auto; padding: 16px 16px calc(88px + env(safe-area-inset-bottom)); }
.stack > * + * { margin-top: 16px; }
.stack-sm > * + * { margin-top: 8px; }
.row { display: flex; gap: 12px; align-items: center; }
.row.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }

.topbar { display: flex; align-items: center; justify-content: space-between; padding: 8px 0 20px; }
.brand { display: flex; align-items: center; gap: 10px; font-family: var(--display); font-size: 1.6rem; letter-spacing: .02em; text-decoration: none; }
.brand img { width: 30px; height: 30px; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
.card.flat { box-shadow: none; }

/* Ecrans d'accueil (connexion, inscription) */
/* margin:auto centre verticalement sans rogner le haut quand le contenu depasse l'ecran */
.auth { min-height: 100dvh; display: flex; flex-direction: column; align-items: center; padding: 24px 16px; }
.auth-inner { width: 100%; max-width: 400px; margin: auto 0; }
.auth-head { margin-bottom: 24px; }
.auth-head .brand { margin-bottom: 28px; }
.auth-foot { margin-top: 20px; text-align: center; color: var(--ink-2); font-size: .9rem; }
.lang-switch { display: flex; gap: 4px; justify-content: center; margin-top: 24px; }
.lang-switch button { background: none; border: 0; padding: 6px 10px; border-radius: 6px; color: var(--ink-3); font: inherit; font-size: .85rem; cursor: pointer; }
.lang-switch button[aria-pressed="true"] { color: var(--ink); font-weight: 600; background: var(--line); }

/* Formulaires */
label { display: block; font-size: .875rem; font-weight: 550; margin-bottom: 6px; color: var(--ink); }
.hint { font-size: .8rem; color: var(--ink-3); margin-top: 6px; }
input, select {
  width: 100%; font: inherit; color: var(--ink);
  background: var(--surface); border: 1px solid var(--line); border-radius: 8px;
  padding: 12px 14px; min-height: 48px; appearance: none;
  transition: border-color .15s, box-shadow .15s;
}
select { background-image: linear-gradient(45deg, transparent 50%, var(--ink-2) 50%), linear-gradient(135deg, var(--ink-2) 50%, transparent 50%);
  background-position: calc(100% - 20px) 50%, calc(100% - 15px) 50%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 36px; }
input:focus, select:focus { outline: none; border-color: var(--ink); box-shadow: 0 0 0 3px rgba(255, 176, 32, .35); }
.field-error input, .field-error select { border-color: var(--danger); }
.form-error { color: var(--danger); font-size: .9rem; background: #fbeceb; border-radius: 8px; padding: 10px 12px; }

/* Boutons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 0 20px; border-radius: 8px; border: 1px solid transparent;
  font: inherit; font-weight: 600; cursor: pointer; text-decoration: none;
  background: var(--ink); color: #fff; transition: transform .08s, background .15s, opacity .15s;
}
.btn:hover { background: #262b33; }
.btn:active { transform: scale(.98); }
.btn:focus-visible, .chip:focus-visible, .tab:focus-visible, .lang-switch button:focus-visible, a:focus-visible {
  outline: 3px solid var(--accent); outline-offset: 2px;
}
.btn[disabled] { opacity: .55; cursor: default; transform: none; }
.btn.block { width: 100%; }
.btn.accent { background: var(--accent); color: var(--accent-ink); }
.btn.accent:hover { background: #f5a50c; }
.btn.ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn.ghost:hover { background: #efece5; }
.btn.danger { background: transparent; color: var(--danger); border-color: transparent; padding: 0 12px; min-height: 40px; }
.btn.danger:hover { background: #fbeceb; }
.btn.sm { min-height: 40px; padding: 0 14px; font-size: .9rem; }

/* Choix de langue */
.choices { display: grid; gap: 12px; }
.choice {
  display: flex; align-items: center; justify-content: space-between;
  width: 100%; min-height: 64px; padding: 0 20px; font: inherit; font-size: 1.1rem; font-weight: 600;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); cursor: pointer; color: var(--ink);
  transition: border-color .15s, transform .08s;
}
.choice:hover { border-color: var(--ink); }
.choice:active { transform: scale(.99); }
.choice .code { font-size: .8rem; color: var(--ink-3); font-weight: 500; letter-spacing: .08em; }

/* Listes */
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; align-items: center; gap: 12px; padding: 14px 0; border-top: 1px solid var(--line); }
.list li:first-child { border-top: 0; padding-top: 0; }
.list li:last-child { padding-bottom: 0; }
.avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--line); display: grid; place-items: center; font-weight: 650; font-size: .85rem; flex: none; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.badge { display: inline-block; font-size: .72rem; font-weight: 650; letter-spacing: .04em; text-transform: uppercase; padding: 3px 8px; border-radius: 999px; background: var(--line); color: var(--ink-2); }
.badge.owner { background: var(--ink); color: #fff; }
.badge.warn { background: #fff1d6; color: #8a5a00; }
.badge.ok { background: #dff2e7; color: var(--ok); }

.notice { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; border-radius: var(--radius); background: #fff1d6; color: #6b4600; font-size: .9rem; font-weight: 550; }

.copy-row { display: flex; gap: 8px; }
.copy-row input { font-size: .85rem; color: var(--ink-2); }

/* Barre d'onglets en bas (telephone) */
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: flex; justify-content: center; gap: 4px;
  padding: 8px 8px calc(8px + env(safe-area-inset-bottom));
  background: rgba(255, 255, 255, .94); backdrop-filter: blur(10px); border-top: 1px solid var(--line);
}
.tab { flex: 1; max-width: 130px; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 4px; border-radius: 8px; text-decoration: none; font-size: .75rem; font-weight: 550; color: var(--ink-3); }
.tab svg { width: 22px; height: 22px; }
.tab[aria-current="page"] { color: var(--ink); }
.tab[aria-current="page"] svg { color: var(--ink); }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { text-align: left; padding: 10px 8px; border-top: 1px solid var(--line); vertical-align: middle; }
th { font-size: .75rem; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-3); font-weight: 600; border-top: 0; }

textarea {
  width: 100%; font: inherit; color: var(--ink); background: var(--surface);
  border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; resize: vertical;
  transition: border-color .15s, box-shadow .15s;
}
textarea:focus { outline: none; border-color: var(--ink); box-shadow: 0 0 0 3px rgba(255, 176, 32, .35); }
input:disabled, select:disabled, textarea:disabled { background: #f1eee8; color: var(--ink-2); }

.tab { position: relative; }
.tab-icon { display: inline-flex; }
.tab-dot { position: absolute; top: 4px; left: calc(50% + 8px); width: 8px; height: 8px; border-radius: 50%; background: var(--danger); box-shadow: 0 0 0 2px #fff; }

.btn-row { display: flex; flex-wrap: wrap; gap: 8px; }
.save-row > .btn { flex: 1; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid2 > *, .grid2 input { min-width: 0; }
input[type="date"] { padding-right: 8px; }
.fold { padding: 0; }
.fold > summary {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 16px 20px; min-height: 56px; cursor: pointer; list-style: none; font-weight: 650;
}
.fold > summary::-webkit-details-marker { display: none; }
.fold > summary::after { content: ''; width: 8px; height: 8px; border-right: 2px solid var(--ink-3); border-bottom: 2px solid var(--ink-3); transform: rotate(45deg); margin-left: auto; transition: transform .15s; }
.fold[open] > summary::after { transform: rotate(-135deg); }
.fold > summary:focus-visible { outline: 3px solid var(--accent); outline-offset: -3px; border-radius: var(--radius); }
.fold > :not(summary) { padding: 0 20px 20px; }
.back { display: inline-block; color: var(--ink-2); text-decoration: none; font-size: .9rem; font-weight: 550; padding: 4px 0; }
.back:hover { color: var(--ink); }
.empty { display: flex; flex-direction: column; align-items: flex-start; gap: 10px; }
.notice-card { border-color: #f3d48a; background: #fffaf0; }
.quote { border-left: 3px solid var(--accent); padding-left: 10px; color: var(--ink-2); white-space: pre-line; }

/* Semaine */
.week-label { font-size: .95rem; }
.day-title { padding-top: 4px; }
.day-title::first-letter, .editor-title::first-letter { text-transform: uppercase; }
.daystrip { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.day {
  display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 0 6px;
  border-radius: 10px; text-decoration: none; color: var(--ink-2); border: 1px solid transparent;
}
.day .dow { font-size: .7rem; text-transform: uppercase; letter-spacing: .05em; }
.day .num { font-size: 1.15rem; font-weight: 650; color: var(--ink); }
.day .dot { width: 5px; height: 5px; border-radius: 50%; background: transparent; }
.day .dot.on { background: var(--ink-3); }
.day[data-today="true"] .num { color: #b97800; }
.day[aria-selected="true"] { background: var(--ink); border-color: var(--ink); }
.day[aria-selected="true"] .dow, .day[aria-selected="true"] .num { color: #fff; }
.day[aria-selected="true"] .dot.on { background: var(--accent); }

/* Seance */
.workout { display: flex; flex-direction: column; gap: 14px; }
.workout-head h2 { font-size: 1rem; }
.block { border-left: 4px solid var(--block); padding-left: 12px; }
.block h3 { font-size: .95rem; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; }
.lines { margin-top: 4px; font-size: .95rem; line-height: 1.45; }
.lines .gap { height: 8px; }

/* Editeur */
.block-edit { border-left: 5px solid var(--block); display: flex; flex-direction: column; gap: 10px; padding: 14px; }
.grid-title { display: grid; grid-template-columns: 1fr 96px; gap: 8px; }
.duration { display: flex; align-items: center; gap: 6px; }
.duration input { padding: 12px 8px; text-align: center; }
.lines-input { font-size: .95rem; line-height: 1.45; min-height: 110px; }
.icon-btn {
  width: 40px; height: 40px; display: grid; place-items: center; border-radius: 8px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink-2); cursor: pointer;
}
.icon-btn svg { width: 18px; height: 18px; }
.icon-btn:hover:not(:disabled) { color: var(--ink); border-color: var(--ink-3); }
.icon-btn:disabled { opacity: .35; cursor: default; }
.icon-btn.danger:hover { color: var(--danger); border-color: var(--danger); }
.icon-btn:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

#toast {
  position: fixed; left: 50%; bottom: calc(96px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 8px; font-size: .9rem; font-weight: 550;
  box-shadow: var(--shadow); z-index: 20; max-width: calc(100% - 32px);
}

.skeleton { height: 120px; border-radius: var(--radius); background: linear-gradient(90deg, #ece8df 0%, #f4f1ea 50%, #ece8df 100%); background-size: 200% 100%; animation: shimmer 1.2s infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }

@media (min-width: 900px) {
  .shell { max-width: 720px; padding-top: 24px; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

.badge { white-space: nowrap; }
.notice-card .btn { white-space: nowrap; }

/* Lien vers une page (reglages > equipe) */
.link-card { display: flex; align-items: center; gap: 14px; text-decoration: none; color: inherit; }
.link-card:hover { border-color: var(--ink-3); }
.link-card .tab-icon svg { width: 24px; height: 24px; }

/* Puces de choix */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex; align-items: center; min-height: 40px; padding: 0 14px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink); font: inherit; font-size: .9rem; font-weight: 600;
  cursor: pointer; text-decoration: none; transition: background .15s, border-color .15s;
}
.chip:hover { border-color: var(--ink-3); }
.chip[aria-selected="true"] { background: var(--ink); border-color: var(--ink); color: #fff; }
.chip.suggest { border-style: dashed; }

.segmented { display: flex; background: #efece5; border-radius: 10px; padding: 4px; gap: 4px; }
.segmented button { flex: 1; min-height: 44px; border: 0; border-radius: 8px; background: transparent; font: inherit; font-weight: 650; color: var(--ink-2); cursor: pointer; }
.segmented button[aria-checked="true"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
.segmented button:focus-visible { outline: 3px solid var(--accent); outline-offset: 1px; }

/* Ecrans */
.code-input { font-family: var(--display); font-size: 2rem; letter-spacing: .2em; text-transform: uppercase; text-align: center; }
.screen-row { align-items: flex-start !important; }

/* Telecommande du timer */
.remote { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 4px; background: #111418; color: #fff; border-color: #111418; }
.remote-phase { font-size: .85rem; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: #a9adb5; min-height: 1.3em; }
.remote-digits { font-family: var(--display); font-size: clamp(4.5rem, 26vw, 8rem); line-height: .95; letter-spacing: .01em; font-variant-numeric: tabular-nums; }
.remote-digits.phase-work { color: #2fbf71; }
.remote-digits.phase-rest { color: #ff6b6b; }
.remote-digits.phase-countdown { color: var(--accent); }
.remote-digits.phase-done { color: #a9adb5; }
.remote-controls { width: 100%; margin-top: 12px; }
.remote-controls .btn { flex: 1; }
.remote-controls .btn.ghost { color: #fff; border-color: #3a3f47; }
.remote-controls .btn.ghost:hover { background: #22262d; }
.remote-controls .btn:not(.accent):not(.ghost) { background: #fff; color: #111418; }
.btn.big { min-height: 60px; font-size: 1.15rem; }
.duration-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.duration-pair select { padding-left: 10px; padding-right: 28px; background-position: calc(100% - 16px) 50%, calc(100% - 11px) 50%; }

/* Scores */
.grid-score { display: grid; grid-template-columns: 1.4fr 1fr; gap: 10px; }
.board-list { list-style: none; margin: 0; padding: 0; }
.board-list li { display: flex; align-items: center; gap: 10px; padding: 6px 0; border-top: 1px solid var(--line); }
.board-list li:first-child { border-top: 0; }
.board-list .rank { width: 28px; text-align: center; font-family: var(--display); font-size: 1.4rem; color: var(--ink-3); flex: none; }
.board-list li:first-child .rank { color: #b97800; }
.board-list .entry { flex: 1; min-width: 0; display: flex; justify-content: space-between; gap: 12px; align-items: center; min-height: 44px; padding: 0 8px; border: 0; background: none; font: inherit; color: inherit; text-align: left; border-radius: 8px; cursor: pointer; }
.board-list .entry:hover { background: #f4f1ea; }
.board-list .entry strong { font-variant-numeric: tabular-nums; }
.board-list .entry:focus-visible { outline: 3px solid var(--accent); }/* Deux durees cote a cote ne tiennent pas sur un telephone : on les empile. */
.grid2:has(.duration-pair) { grid-template-columns: 1fr; }

/* Personnalisation */
.color-input { width: 44px; height: 44px; padding: 2px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); flex: none; cursor: pointer; }
.check { display: flex; align-items: center; gap: 10px; font-weight: 500; margin: 0; cursor: pointer; }
.check input { width: 20px; height: 20px; min-height: 0; accent-color: var(--ink); }
.picker-row { display: flex; align-items: center; gap: 12px; margin: 0; font-weight: 550; }
.logo-thumb { width: 72px; height: 72px; object-fit: contain; border-radius: 12px; border: 1px solid var(--line); background: #fff; flex: none; padding: 6px; }
.empty-logo { display: grid; place-items: center; font-family: var(--display); font-size: 1.6rem; color: var(--ink-3); }
.proposals { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.proposal { min-height: 64px; border-radius: 10px; border: 3px solid; font: inherit; font-weight: 700; cursor: pointer; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; }
.proposal .sw { width: 28px; height: 8px; border-radius: 4px; }
.proposal:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.contrast-ok { color: var(--ok); font-weight: 600; }
.contrast-bad { color: var(--danger); font-weight: 600; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

/* Apercu TV (16:9) */
.tv-preview { aspect-ratio: 16 / 9; background: var(--bg); color: var(--ink); border-radius: 8px; overflow: hidden; display: flex; flex-direction: column; font-family: "Barlow Semi Condensed", var(--font); container-type: inline-size; }
.tvp-head { display: flex; align-items: center; justify-content: space-between; padding: 2.4cqw 3cqw 1.4cqw; gap: 2cqw; }
.tvp-box { display: flex; align-items: center; gap: 1.4cqw; font-family: var(--display); font-size: 4cqw; line-height: 1; }
.tvp-box img { height: 5cqw; width: auto; }
.tvp-act { font-family: var(--display); font-size: 3.4cqw; color: var(--accent); }
.tvp-clock { font-family: var(--display); font-size: 4.4cqw; }
.tvp-blocks { flex: 1; display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 1.6cqw; padding: 0 3cqw 2cqw; min-height: 0; }
.tvp-block { background: var(--surface); border-top: .8cqw solid var(--block); border-radius: 1cqw; padding: 1.4cqw 1.6cqw; overflow: hidden; }
.tvp-title { font-family: var(--display); color: var(--block); font-size: 3cqw; line-height: 1; margin-bottom: .8cqw; }
.tvp-lines { font-size: 2.2cqw; font-weight: 600; line-height: 1.25; }
.tvp-ticker { background: var(--accent); color: var(--accent-ink); font-weight: 700; font-size: 2.4cqw; padding: 1cqw 3cqw; white-space: nowrap; overflow: hidden; }
[hidden] { display: none !important; }

/* Import */
.or { text-align: center; color: var(--ink-3); font-size: .8rem; font-weight: 600; text-transform: uppercase; letter-spacing: .1em; }
.block-edit-lite { border-left: 4px solid var(--block); padding-left: 10px; display: flex; flex-direction: column; gap: 6px; }
.block-edit-lite input { min-height: 40px; padding: 8px 10px; font-weight: 650; }
.dimmed { opacity: .45; }
/* Abonnement */
a.notice { text-decoration: none; }
.bad-notice { background: #fbeceb; color: var(--danger); }
.ok-notice { background: #dff2e7; color: var(--ok); }