:root {
  --accent: #3d5fb4;
  --bg: #faf8f4;
  --card: #ffffff;
  --text: #2a2a2a;
  --muted: #767267;
  --border: #e7e2d8;
  --radius: 18px;
  --ok: #3f8f5f;
  --mid: #d9a441;
  --off: #c9c3b6;
  font-size: 18px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

#app {
  min-height: 100vh;
}

#app.has-bottom-nav {
  padding-bottom: 90px;
}

button, .btn {
  font: inherit;
  cursor: pointer;
  border: none;
  border-radius: 14px;
  padding: 14px 18px;
  background: var(--accent);
  color: white;
  touch-action: manipulation;
}

.secondary {
  background: var(--card);
  color: var(--text);
  border: 1px solid var(--border);
}

button.ghost {
  background: transparent;
  color: var(--accent);
  padding: 8px 10px;
}

button.danger {
  background: #c1503f;
}

input, textarea, select {
  font: inherit;
  padding: 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  width: 100%;
  background: white;
  color: var(--text);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--accent);
  color: white;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.topbar h1 {
  font-size: 1.1rem;
  margin: 0;
  flex: 1;
}

.topbar .back {
  background: rgba(255,255,255,0.18);
  padding: 8px 12px;
  border-radius: 10px;
}

.container {
  padding: 16px;
  max-width: 560px;
  margin: 0 auto;
}

/* ---- Sélecteur d'enfant ---- */
.child-select-screen {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.child-select-screen {
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

.app-title {
  text-align: center;
  padding: clamp(6px, 2.5vh, 20px) 0 4px;
  color: var(--muted);
  font-size: clamp(0.75rem, 2.2vh, 0.95rem);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  flex-shrink: 0;
}

.child-grid {
  flex: 1;
  min-height: 0;
  display: flex;
  gap: clamp(8px, 2vh, 14px);
  padding: clamp(8px, 2vh, 14px);
}

.child-card {
  flex: 1;
  min-width: 0;
  min-height: 0;
  background: var(--card);
  border-radius: 28px;
  padding: clamp(10px, 3vh, 24px) 16px;
  text-align: center;
  box-shadow: 0 2px 10px rgba(0,0,0,0.06);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(6px, 2vh, 18px);
  border: 3px solid transparent;
}

.child-card .avatar {
  font-size: min(14vw, 13vh, 6rem);
  width: min(38vw, 34vh, 190px);
  height: min(38vw, 34vh, 190px);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--child-color, var(--accent));
  flex-shrink: 0;
}

.child-card .name {
  font-weight: 700;
  font-size: clamp(1rem, 4vh, 1.6rem);
}

.child-card .level {
  color: var(--muted);
  font-size: clamp(0.8rem, 2.6vh, 1.05rem);
}

@media (max-width: 480px) and (orientation: portrait) {
  .child-grid { flex-direction: column; }
}

/* ---- Cartes génériques ---- */
.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 14px;
  box-shadow: 0 1px 6px rgba(0,0,0,0.05);
}

.section-title {
  font-size: 1rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--muted);
  margin: 22px 0 10px;
}

/* ---- Page de garde : activités du jour ---- */
.activity-card {
  border: 1px solid var(--border);
}

.activity-card .titre {
  font-weight: 700;
  font-size: 1.05rem;
  margin-bottom: 4px;
}

.activity-card .meta {
  color: var(--muted);
  font-size: 0.85rem;
  margin-bottom: 8px;
}

.tag {
  display: inline-block;
  background: #eef1fb;
  color: var(--accent);
  border-radius: 100px;
  padding: 3px 10px;
  font-size: 0.78rem;
  margin: 2px 4px 2px 0;
}

/* ---- Navigation basse ---- */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--card);
  border-top: 1px solid var(--border);
  display: flex;
  padding: 8px 4px calc(8px + env(safe-area-inset-bottom));
  z-index: 10;
}

.bottom-nav a {
  flex: 1;
  text-align: center;
  color: var(--muted);
  text-decoration: none;
  font-size: 0.78rem;
  padding: 6px 2px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.bottom-nav a.active {
  color: var(--accent);
  font-weight: 700;
}

.bottom-nav .icon { font-size: 1.3rem; }

/* ---- Bouton flottant + ---- */
.fab {
  position: fixed;
  right: 18px;
  bottom: 84px;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  font-size: 1.8rem;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 14px rgba(0,0,0,0.2);
  z-index: 11;
}

/* ---- Timeline ---- */
.timeline-item {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
}

.timeline-photos {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.timeline-photos img {
  width: 72px;
  height: 72px;
  object-fit: cover;
  border-radius: 10px;
}

.timeline-date {
  font-weight: 700;
  font-size: 0.95rem;
  margin-bottom: 2px;
}

/* ---- Photos dans le formulaire de séance ---- */
.photo-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 10px 0;
}

.photo-thumb {
  position: relative;
  width: 88px;
  height: 88px;
}

.photo-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 12px;
}

.doc-thumb {
  width: 100%;
  height: 100%;
  border-radius: 12px;
  background: #eef1fb;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 6px;
  overflow: hidden;
}

.doc-thumb-icon {
  font-size: 1.6rem;
}

.doc-thumb-name {
  font-size: 0.62rem;
  color: var(--accent);
  text-align: center;
  word-break: break-word;
  line-height: 1.1;
  max-height: 2.2em;
  overflow: hidden;
}

.photo-thumb .remove {
  position: absolute;
  top: -6px;
  right: -6px;
  background: #c1503f;
  color: white;
  border-radius: 50%;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
}

/* ---- Barres de progression ---- */
.progress-item {
  margin-bottom: 14px;
}

.progress-item .libelle {
  font-size: 0.95rem;
  margin-bottom: 6px;
}

.progress-bar-track {
  background: #eee;
  border-radius: 100px;
  height: 12px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  border-radius: 100px;
}

.progress-bar-fill.a_voir { width: 8%; background: var(--off); }
.progress-bar-fill.vu_en_cours { width: 55%; background: var(--mid); }
.progress-bar-fill.vu_acquis { width: 100%; background: var(--ok); }

.status-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-right: 6px;
}
.status-dot.a_voir { background: var(--off); }
.status-dot.vu_en_cours { background: var(--mid); }
.status-dot.vu_acquis { background: var(--ok); }

.discipline-header {
  font-weight: 700;
  font-size: 1.05rem;
  margin: 20px 0 8px;
  color: var(--accent);
  cursor: pointer;
}

.discipline-block {
  margin-bottom: 6px;
}

.discipline-block:not([open]) .discipline-header {
  margin-bottom: 0;
}

.discipline-count {
  font-weight: 400;
  font-size: 0.8rem;
  color: var(--muted);
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}

.checkbox-row:last-child { border-bottom: none; }

.checkbox-row input[type="checkbox"] {
  width: 22px;
  height: 22px;
}

.statut-select {
  margin-left: auto;
  width: auto;
  font-size: 0.85rem;
  padding: 6px 8px;
}

.empty-state {
  text-align: center;
  color: var(--muted);
  padding: 40px 20px;
}

.field {
  margin-bottom: 16px;
}

.field label {
  display: block;
  font-weight: 600;
  margin-bottom: 6px;
  font-size: 0.92rem;
}

.actions-row {
  display: flex;
  gap: 10px;
  margin-top: 20px;
}

.actions-row button { flex: 1; }

.discipline-progress-card summary::-webkit-details-marker { display: none; }
.discipline-progress-card summary { list-style: none; }

.niveau-subheader {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin: 12px 0 4px;
}

.login-screen {
  height: 100vh;
  height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.login-card {
  background: var(--card);
  border-radius: 24px;
  padding: 32px 24px;
  width: 100%;
  max-width: 340px;
  text-align: center;
  box-shadow: 0 2px 14px rgba(0,0,0,0.08);
}

.login-title {
  font-weight: 700;
  font-size: 1.3rem;
  margin-bottom: 6px;
}

.login-sub {
  color: var(--muted);
  font-size: 0.9rem;
  margin-bottom: 20px;
}

.login-input {
  text-align: center;
  font-size: 1.4rem;
  letter-spacing: 0.15em;
  margin-bottom: 12px;
}

.login-error {
  color: #c1503f;
  font-size: 0.88rem;
  margin-bottom: 12px;
}

.login-card button {
  width: 100%;
}
