:root {
  --bg: #0b0b0b;
  --card: #141414;
  --card-2: #1b1b1b;
  --stroke: rgba(255, 255, 255, 0.12);
  --stroke-strong: rgba(255, 255, 255, 0.24);
  --text: rgba(255, 255, 255, 0.92);
  --muted: rgba(255, 255, 255, 0.58);
  --accent: #00e676;
  --accent-ink: #00210f;
  --accent-soft: rgba(0, 230, 118, 0.12);
  --danger: #ff5c5c;
  --danger-soft: rgba(255, 92, 92, 0.12);
  --warn: #ffc857;
  --paper: #e4d0ab;
  --radius: 14px;
  --radius-sm: 10px;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  /* îlot / encoche de l'iPhone couché */
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.45;
  min-height: 100vh;
  min-height: 100dvh;
  -webkit-tap-highlight-color: transparent;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3 { margin: 0; line-height: 1.2; }
h1 { font-size: 1.25rem; font-weight: 700; }
h2 { font-size: 1.05rem; font-weight: 700; }
h3 { font-size: 0.95rem; font-weight: 650; }

.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.num { font-variant-numeric: tabular-nums; }
.hidden { display: none !important; }

/* ---------- Structure ---------- */

.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  padding-top: max(10px, env(safe-area-inset-top));
  background: rgba(11, 11, 11, 0.92);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--stroke);
}
.topbar .spacer { flex: 1; }

.container {
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
  padding: 16px 16px calc(32px + env(safe-area-inset-bottom));
}

.stack { display: flex; flex-direction: column; gap: 12px; }
.row { display: flex; align-items: center; gap: 10px; }
.row.wrap { flex-wrap: wrap; }
.row.between { justify-content: space-between; }

.card {
  background: var(--card);
  border: 1px solid var(--stroke);
  border-radius: var(--radius);
  padding: 16px;
}

.section-title {
  margin: 22px 2px 10px;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

/* ---------- Marque ---------- */

.brand { display: inline-flex; align-items: center; gap: 9px; color: var(--text); font-weight: 800; letter-spacing: 0.01em; font-size: 1.1rem; }
.brand:hover { text-decoration: none; }
.brand-mark { width: 26px; height: 26px; flex: none; }

/* ---------- Boutons ---------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--stroke-strong);
  background: var(--card-2);
  color: var(--text);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s, border-color 0.15s, opacity 0.15s;
}
.btn:hover { background: #222; text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.4; cursor: default; transform: none; }
.btn:focus-visible, .input:focus-visible, .select:focus-visible, .icon-btn:focus-visible, .tile:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: #33eb91; }
.btn-danger { color: var(--danger); border-color: rgba(255, 92, 92, 0.4); }
.btn-danger:hover { background: var(--danger-soft); }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-ghost:hover { background: rgba(255, 255, 255, 0.06); }
.btn-block { width: 100%; }
.btn-sm { min-height: 34px; padding: 6px 12px; font-size: 0.9rem; }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; flex: none;
  border-radius: 10px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text);
  cursor: pointer;
}
.icon-btn:hover { background: rgba(255, 255, 255, 0.07); text-decoration: none; }
.icon-btn svg, .btn svg { width: 20px; height: 20px; flex: none; }

/* ---------- Formulaires ---------- */

.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 0.85rem; color: var(--muted); font-weight: 600; }

.input, .select {
  width: 100%;
  min-height: 46px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--stroke-strong);
  background: #0f0f0f;
  color: var(--text);
  font: inherit;
}
.input::placeholder { color: rgba(255, 255, 255, 0.3); }
.select {
  appearance: none; -webkit-appearance: none;
  padding-right: 38px;
  cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 20px) 50%, calc(100% - 15px) 50%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}
.select:disabled { opacity: 0.45; cursor: default; }
.select option { background: #161616; color: var(--text); }

.form-error {
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--danger-soft);
  color: #ffb3b3;
  font-size: 0.9rem;
}

/* ---------- Tuiles d'accueil ---------- */

.tiles { display: grid; grid-template-columns: 1fr; gap: 12px; }
@media (min-width: 560px) { .tiles { grid-template-columns: 1fr 1fr; } }

.tile {
  display: flex; align-items: center; gap: 14px;
  padding: 18px;
  border-radius: var(--radius);
  border: 1px solid var(--stroke);
  background: var(--card);
  color: var(--text);
  text-decoration: none;
  transition: border-color 0.15s, background 0.15s;
}
.tile:hover { border-color: var(--stroke-strong); background: var(--card-2); text-decoration: none; }
.tile-icon {
  width: 46px; height: 46px; flex: none;
  display: grid; place-items: center;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
}
.tile-icon svg { width: 24px; height: 24px; }
.tile.primary { border-color: rgba(0, 230, 118, 0.45); background: linear-gradient(180deg, rgba(0, 230, 118, 0.10), rgba(0, 230, 118, 0.03)); }
.tile.primary .tile-icon { background: var(--accent); color: var(--accent-ink); }
.tile-title { font-weight: 700; }
.tile-sub { font-size: 0.88rem; color: var(--muted); }

/* ---------- Divers ---------- */

.badge {
  display: inline-flex; align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
  background: rgba(255, 255, 255, 0.08);
  color: var(--muted);
  white-space: nowrap;
}
.badge.accent { background: var(--accent-soft); color: var(--accent); }
.badge.warn { background: rgba(255, 200, 87, 0.12); color: var(--warn); }

.list { display: flex; flex-direction: column; }
.list-item {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 2px;
  border-top: 1px solid var(--stroke);
}
.list-item:first-child { border-top: none; }
.list-item .grow { flex: 1; min-width: 0; }
button.list-item {
  width: 100%; text-align: left;
  background: none; border-left: 0; border-right: 0; border-bottom: 0;
  color: inherit; font: inherit; cursor: pointer;
}
button.list-item:first-child { border-top: none; }
button.list-item:hover { background: rgba(255, 255, 255, 0.03); }

.score-big { font-size: 1.25rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.score-big small { font-size: 0.8rem; color: var(--muted); font-weight: 600; margin-left: 3px; }

.empty {
  text-align: center;
  padding: 32px 16px;
  color: var(--muted);
}

.banner {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(0, 230, 118, 0.35);
  background: var(--accent-soft);
}

/* ---------- Fenêtres modales ---------- */

.modal-back {
  position: fixed; inset: 0; z-index: 100;
  display: flex; align-items: flex-end; justify-content: center;
  padding: 16px;
  background: rgba(0, 0, 0, 0.65);
  animation: fade 0.15s ease-out;
}
@media (min-width: 560px) { .modal-back { align-items: center; } }
.modal {
  width: 100%; max-width: 420px;
  max-height: calc(100dvh - 32px);
  overflow: auto;
  background: #161616;
  border: 1px solid var(--stroke-strong);
  border-radius: 18px;
  padding: 20px;
  display: flex; flex-direction: column; gap: 14px;
}
.modal.wide { max-width: 640px; }
.modal-actions { display: flex; flex-direction: column; gap: 8px; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

/* ---------- Notifications ---------- */

.toast {
  position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom)); z-index: 200;
  transform: translateX(-50%);
  max-width: calc(100% - 32px);
  padding: 12px 16px;
  border-radius: 12px;
  background: #262626;
  border: 1px solid var(--stroke-strong);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  font-size: 0.95rem;
  animation: fade 0.15s ease-out;
}
.toast.error { border-color: rgba(255, 92, 92, 0.5); }

/* ---------- Comptes ---------- */

.avatar { display: inline-block; border-radius: 50%; object-fit: cover; flex: none; background: #222; }
.avatar-initials { display: inline-flex; align-items: center; justify-content: center; font-weight: 800; color: var(--accent-ink); background: var(--paper); }
.badge.premium { background: rgba(0, 230, 118, 0.14); color: var(--accent); }
.premium-list { margin: 4px 0 6px; padding-left: 20px; color: var(--muted); font-size: 0.92rem; }
.premium-list li { margin: 4px 0; }
.premium-gate { display: flex; flex-direction: column; gap: 12px; align-items: flex-start; }
.gate-icon { width: 46px; height: 46px; border-radius: 12px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); }
.gate-icon svg { width: 24px; height: 24px; }
.tile .lock { margin-left: auto; color: var(--muted); display: inline-flex; }
.tile .lock svg { width: 18px; height: 18px; }
.tile .tile-text { flex: 1; min-width: 0; }

/* Cases à cocher dans les fenêtres (ex. calibres autorisés d'une discipline) */
.field-label { font-size: 0.85rem; color: var(--muted); font-weight: 600; }
.check-list { max-height: 240px; overflow: auto; border: 1px solid var(--stroke-strong); border-radius: var(--radius-sm); background: #0f0f0f; }
.check-row { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-top: 1px solid var(--stroke); cursor: pointer; }
.check-row:first-child { border-top: none; }
.check-row input { width: 20px; height: 20px; accent-color: var(--accent); flex: none; }
