/* Application parent — conçue d'abord pour le téléphone */
body { background: var(--bg); }
.app { max-width: 560px; margin: 0 auto; min-height: 100vh; min-height: 100dvh; padding-bottom: calc(84px + env(safe-area-inset-bottom)); }

/* En-tête */
.topbar { position: sticky; top: 0; z-index: 20; background: var(--brand); color: #fff; padding: calc(8px + env(safe-area-inset-top)) 12px 0; }
.topbar-row { display: flex; align-items: center; gap: 10px; min-height: 52px; }
.topbar .logo { width: 38px; height: 38px; border-radius: 10px; background: #fff; overflow: hidden; flex: none; }
.topbar .logo img { width: 100%; height: 100%; object-fit: contain; }
.topbar .t1 { font-family: var(--font-display); font-weight: var(--fw-semibold); font-size: var(--fs-4); line-height: 1.1; }
.topbar .t2 { font-size: var(--fs-1); opacity: .85; font-weight: var(--fw-light) }
.topbar .icon-btn { color: #fff; }
.topbar .weave { margin: 8px -12px 0; }

/* Sélecteur d'enfant */
.child-bar { background: var(--surface); border-bottom: 1px solid var(--line); padding: 10px 14px; position: sticky; top: calc(65px + env(safe-area-inset-top)); z-index: 15; }
.child-switch { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; margin: 0 -14px; padding: 0 14px 8px; }
.child-switch::-webkit-scrollbar { display: none; }
.child-pill { display: flex; align-items: center; gap: 8px; padding: 5px 12px 5px 5px; border-radius: 999px; border: 1.5px solid var(--line-strong); background: #fff; cursor: pointer; white-space: nowrap; font-weight: var(--fw-semibold); min-height: 44px; }
.child-pill img { width: 32px; height: 32px; border-radius: 50%; object-fit: cover; }
.child-pill[aria-pressed="true"] { border-color: var(--brand); background: var(--brand-soft); color: var(--brand-ink); }
.child-pill .n { background: var(--accent); color: #fff; font-size: var(--fs-1); border-radius: 9px; min-width: 18px; height: 18px; display: grid; place-items: center; padding: 0 5px; }
.child-context { display: flex; align-items: center; gap: 8px; font-size: var(--fs-2); color: var(--ink-2); flex-wrap: wrap; font-weight: var(--fw-light) }
.child-context strong { color: var(--ink); font-size: var(--fs-3); }

main.page { padding: 16px 14px 24px; }
.section { margin-top: 22px; }
.section:first-child { margin-top: 0; }
.section-head { display: flex; align-items: baseline; gap: 10px; margin-bottom: 10px; }
.section-head h2 { flex: 1; }
.section-head .num { font-family: var(--font-display); color: var(--brand-2); font-size: var(--fs-5); font-weight: var(--fw-bold) }
.link-btn { background: none; border: 0; color: var(--brand); font-weight: var(--fw-regular); cursor: pointer; padding: 8px 0; font-size: var(--fs-2); }

/* Carte */
.card-stage { max-width: 290px; margin: 0 auto; perspective: 1200px; }
.card-stage.paysage { max-width: 420px; }
.card-flip { position: relative; transition: transform .6s cubic-bezier(.2,.7,.2,1); transform-style: preserve-3d; }
.card-flip.back { transform: rotateY(180deg); }
.card-flip > .face { backface-visibility: hidden; -webkit-backface-visibility: hidden; }
.card-flip > .face.verso { position: absolute; top: 0; right: 0; bottom: 0; left: 0; transform: rotateY(180deg); }
.card-actions { display: flex; justify-content: center; gap: 8px; margin-top: 12px; }
.card-note { text-align: center; font-size: var(--fs-1); color: var(--ink-3); margin-top: 6px; font-weight: var(--fw-light) }

/* Événements */
.ev { display: flex; gap: 12px; padding: 12px 0; align-items: flex-start; }
.ev-date { width: 54px; flex: none; text-align: center; border-radius: 12px; background: var(--brand-soft); color: var(--brand-ink); padding: 6px 0; line-height: 1.1; }
.ev-date .d { font-family: var(--font-display); font-size: var(--fs-5); font-weight: var(--fw-semibold); }
.ev-date .m { font-size: var(--fs-1); font-weight: var(--fw-semibold); text-transform: uppercase; letter-spacing: .04em; }
.ev-body { flex: 1; min-width: 0; }
.ev-title { font-weight: var(--fw-semibold); }
.ev-meta { font-size: var(--fs-2); color: var(--ink-2); display: flex; flex-wrap: wrap; gap: 4px 12px; margin-top: 2px; font-weight: var(--fw-light) }
.ev-meta .ic svg { width: 14px; height: 14px; }
.ev.cancelled .ev-title { text-decoration: line-through; color: var(--ink-3); }
.ev.cancelled .ev-date { background: var(--surface-2); color: var(--ink-3); }

/* Annonces */
.ann { display: block; width: 100%; text-align: left; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 14px; cursor: pointer; position: relative; }
.ann + .ann { margin-top: 10px; }
.ann.unread { border-left: 4px solid var(--accent); }
.ann-title { font-weight: var(--fw-semibold); font-size: var(--fs-3); padding-right: 18px; }
.ann-excerpt { color: var(--ink-2); font-size: var(--fs-2); margin-top: 4px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; font-weight: var(--fw-light) }
.ann-meta { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 8px; font-size: var(--fs-1); color: var(--ink-3); font-weight: var(--fw-light) }
.ann .new { position: absolute; top: 14px; right: 14px; width: 10px; height: 10px; border-radius: 50%; background: var(--accent); }
.ann-body { white-space: pre-wrap; font-size: var(--fs-3); }
.question { border: 2px solid var(--brand-2); background: var(--brand-2-soft); border-radius: 16px; padding: 16px; }
.question h3 { font-family: var(--font); font-weight: var(--fw-semibold); font-size: var(--fs-3); margin-bottom: 12px; }
.answers { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.answer { min-height: 56px; border-radius: 14px; border: 2px solid var(--line-strong); background: #fff; font-weight: var(--fw-semibold); font-size: var(--fs-4); cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 8px; }
.answer[aria-pressed="true"].oui { background: var(--ok); border-color: var(--ok); color: #fff; }
.answer[aria-pressed="true"].non { background: var(--ink-2); border-color: var(--ink-2); color: #fff; }
.answer:disabled { cursor: default; }
.answer:disabled:not([aria-pressed="true"]) { opacity: .55; }
.answer svg { width: 20px; height: 20px; }

/* Calendrier */
.months { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; padding-bottom: 4px; margin: 0 -14px 12px; padding-left: 14px; padding-right: 14px; }
.months::-webkit-scrollbar { display: none; }
.months button { flex: none; border: 1.5px solid var(--line-strong); background: #fff; border-radius: 999px; padding: 6px 12px; font-weight: var(--fw-regular); font-size: var(--fs-2); cursor: pointer; min-height: 38px; }
.months button[aria-pressed="true"] { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: var(--fw-semibold); }
.months button .c { display: inline-block; margin-left: 4px; font-size: var(--fs-1); opacity: .75; font-weight: var(--fw-light) }
.cal-head { display: flex; align-items: center; gap: 6px; margin-bottom: 8px; }
.cal-head h2 { flex: 1; text-align: center; text-transform: capitalize; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal-grid .dow { text-align: center; font: var(--t-legende); color: var(--ink-3); padding: 4px 0; text-transform: uppercase; }
.cal-day { min-height: 44px; aspect-ratio: 1 / 1.05; border-radius: 10px; border: 0; background: var(--surface); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; cursor: pointer;
  font-weight: var(--fw-regular); font-size: var(--fs-3); line-height: 1; font-variant-numeric: tabular-nums; color: var(--ink); position: relative; -webkit-tap-highlight-color: transparent; }
.cal-day.out { visibility: hidden; }
.cal-day.we { background: var(--surface-2); }
.cal-day .dots { display: flex; gap: 2px; flex-wrap: wrap; justify-content: center; max-width: 80%; }
.cal-day .dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--c); display: block; }
/* Date du jour : anneau à la couleur de l'école, à l'extérieur de la case */
.cal-day.today { font-weight: var(--fw-semibold); box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--brand); z-index: 1; }
/* Jour choisi : anneau foncé plus épais ; case foncée si le jour n'a pas d'événement */
.cal-day.sel { background: var(--ink); color: #fff; font-weight: var(--fw-semibold); box-shadow: 0 0 0 2px var(--surface), 0 0 0 5px var(--ink); z-index: 2; }
.cal-day.sel .dots i { outline: 1.5px solid #fff; }
/* Jours porteurs d'un événement : case entière à la couleur du type (navigateurs récents ; sinon, les points restent) */
@supports selector(:has(*)) {
.cal-day:has(.dots i.cat-activite) { --ev1: #2F7A4F; --ev1t: #FFFFFF; }
.cal-day:has(.dots i.cat-reunion) { --ev1: #7A4FA0; --ev1t: #FFFFFF; }
.cal-day:has(.dots i.cat-devoir) { --ev1: #2E62A3; --ev1t: #FFFFFF; }
.cal-day:has(.dots i.cat-composition) { --ev1: #B3352B; --ev1t: #FFFFFF; }
.cal-day:has(.dots i.cat-conge) { --ev1: #E3A72F; --ev1t: #2A1E00; }
/* Calendrier officiel : le férié l'emporte sur les congés, puis examens, rentrée et repères */
.cal-day:has(.dots i.cat-repere) { --ev1: #6D4C41; --ev1t: #FFFFFF; }
.cal-day:has(.dots i.cat-rentree) { --ev1: #455A64; --ev1t: #FFFFFF; }
.cal-day:has(.dots i.cat-examen) { --ev1: #00838F; --ev1t: #FFFFFF; }
.cal-day:has(.dots i.cat-ferie) { --ev1: #C2185B; --ev1t: #FFFFFF; }
.cal-day:has(.dots i.cat-conge):has(.dots i.cat-activite) { --ev2: #2F7A4F; --ev2-ring: rgba(255,255,255,.9); }
.cal-day:has(.dots i.cat-conge):has(.dots i.cat-reunion) { --ev2: #7A4FA0; --ev2-ring: rgba(255,255,255,.9); }
.cal-day:has(.dots i.cat-conge):has(.dots i.cat-devoir) { --ev2: #2E62A3; --ev2-ring: rgba(255,255,255,.9); }
.cal-day:has(.dots i.cat-conge):has(.dots i.cat-composition) { --ev2: #B3352B; --ev2-ring: rgba(255,255,255,.9); }
.cal-day:has(.dots i.cat-composition):has(.dots i.cat-activite) { --ev2: #2F7A4F; --ev2-ring: rgba(255,255,255,.9); }
.cal-day:has(.dots i.cat-composition):has(.dots i.cat-reunion) { --ev2: #7A4FA0; --ev2-ring: rgba(255,255,255,.9); }
.cal-day:has(.dots i.cat-composition):has(.dots i.cat-devoir) { --ev2: #2E62A3; --ev2-ring: rgba(255,255,255,.9); }
.cal-day:has(.dots i.cat-devoir):has(.dots i.cat-activite) { --ev2: #2F7A4F; --ev2-ring: rgba(255,255,255,.9); }
.cal-day:has(.dots i.cat-devoir):has(.dots i.cat-reunion) { --ev2: #7A4FA0; --ev2-ring: rgba(255,255,255,.9); }
.cal-day:has(.dots i.cat-reunion):has(.dots i.cat-activite) { --ev2: #2F7A4F; --ev2-ring: rgba(255,255,255,.9); }
  .cal-day:has(.dots i:not(.cat-autre)) { background: var(--ev1); color: var(--ev1t); font-weight: var(--fw-semibold); }
  .cal-day:has(.dots i:not(.cat-autre)) .dots { display: none; }
  /* Deuxième type le même jour : liseré de sa couleur en bas de la case */
  .cal-day:has(.dots i:not(.cat-autre))::after { content: ''; position: absolute; left: 7px; right: 7px; bottom: 5px; height: 5px; border-radius: 3px; background: var(--ev2, transparent); box-shadow: 0 0 0 1.5px var(--ev2-ring, transparent); }
  .cal-day.sel:has(.dots i:not(.cat-autre)) { background: var(--ev1); color: var(--ev1t); }
}
/* Légende des couleurs, sous le calendrier */
.legend { display: flex; flex-wrap: wrap; gap: 8px 16px; font: var(--t-secondaire); color: var(--ink-2); margin-top: 14px; }
.legend span { display: inline-flex; align-items: center; gap: 7px; }
.legend .cat-dot { width: 16px; height: 16px; border-radius: 5px; }
.week-block + .week-block { margin-top: 14px; }
.week-title { font-size: var(--fs-1); font-weight: var(--fw-light); letter-spacing: .03em; text-transform: uppercase; color: var(--ink-3); margin-bottom: 4px; }

/* Résultats */
.res-table { width: 100%; border-collapse: collapse; font-size: var(--fs-3); }
.res-table th, .res-table td { padding: 9px 6px; text-align: left; border-bottom: 1px solid var(--line); }
.res-table td.n { text-align: right; font-variant-numeric: tabular-nums; font-weight: var(--fw-bold); white-space: nowrap; }
.res-table th { font-size: var(--fs-1); text-transform: uppercase; letter-spacing: .03em; color: var(--ink-3); }
.avg { display: flex; align-items: baseline; gap: 8px; margin-top: 12px; padding: 12px 14px; background: var(--brand-soft); border-radius: 12px; }
.avg b { font-family: var(--font-display); font-size: var(--fs-6); color: var(--brand-ink); font-weight: var(--fw-bold) }

/* Barre du bas */
.tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; background: rgba(255,255,255,.97); backdrop-filter: blur(8px); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
.tabbar nav { max-width: 560px; margin: 0 auto; display: grid; grid-template-columns: repeat(5, 1fr); }
.tabbar a { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 2px 8px; text-decoration: none; color: var(--ink-3); font-size: var(--fs-1); font-weight: var(--fw-light); position: relative; min-height: 60px; }
.tabbar a svg { width: 24px; height: 24px; }
.tabbar a[aria-current="page"] { color: var(--brand); font-weight: var(--fw-semibold); }
.tabbar a[aria-current="page"]::before { content: ''; position: absolute; top: 0; left: 30%; right: 30%; height: 3px; border-radius: 0 0 3px 3px; background: var(--brand); }
.tabbar .badge { position: absolute; top: 5px; left: calc(50% + 6px); background: var(--accent); color: #fff; font-size: var(--fs-1); min-width: 17px; height: 17px; border-radius: 9px; display: grid; place-items: center; padding: 0 4px; }

/* Menu Plus */
.menu-list a, .menu-list button { display: flex; align-items: center; gap: 14px; width: 100%; padding: 14px 4px; background: none; border: 0; text-align: left; color: var(--ink); text-decoration: none; font-weight: var(--fw-semibold); cursor: pointer; min-height: 56px; }
.menu-list .ic svg { width: 22px; height: 22px; color: var(--brand); }
.menu-list .desc { display: block; font-weight: var(--fw-light); font-size: var(--fs-2); color: var(--ink-2); }

/* Notifications */
.notif { display: flex; gap: 12px; padding: 12px 4px; align-items: flex-start; cursor: pointer; }
.notif .nic { width: 38px; height: 38px; border-radius: 12px; background: var(--brand-soft); color: var(--brand); display: grid; place-items: center; flex: none; }
.notif .nic svg { width: 20px; height: 20px; }
.notif.unread .t { font-weight: var(--fw-semibold); }
.notif.unread::after { content: ''; width: 9px; height: 9px; border-radius: 50%; background: var(--accent); margin-top: 6px; flex: none; }

/* Connexion */
.auth { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; }
.auth-hero { background: var(--brand); color: #fff; padding: calc(36px + env(safe-area-inset-top)) 24px 30px; text-align: center; position: relative; }
.auth-hero .logo { width: 84px; height: 84px; border-radius: 22px; background: #fff; margin: 0 auto 14px; overflow: hidden; box-shadow: 0 6px 20px rgba(0,0,0,.2); }
.auth-hero .logo img { width: 100%; height: 100%; object-fit: contain; }
.auth-hero h1 { font-size: var(--fs-6); font-weight: var(--fw-bold) }
.auth-hero p { opacity: .88; margin: 6px 0 0; }
.auth-hero .weave { position: absolute; left: 0; right: 0; bottom: 0; }
.auth-body { flex: 1; padding: 24px 20px 30px; max-width: 460px; width: 100%; margin: 0 auto; }
.auth-foot { text-align: center; font-size: var(--fs-1); color: var(--ink-3); padding: 16px; font-weight: var(--fw-light) }
.provisional { display: inline-block; margin-top: 10px; font-size: var(--fs-1); font-weight: var(--fw-semibold); letter-spacing: .05em; text-transform: uppercase; background: rgba(255,255,255,.16); border: 1px dashed rgba(255,255,255,.5); border-radius: 6px; padding: 2px 8px; }
.code-input { font-family: ui-monospace, 'SFMono-Regular', Menlo, monospace; letter-spacing: .2em; text-transform: uppercase; font-size: var(--fs-4); text-align: center; }

/* Calendrier officiel : trimestre en cours, jours de cours restants, arrêté */
.cal-official { display: grid; gap: 10px; }
.cal-official .kpis2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.cal-official .kpi2 { background: var(--surface-2); border-radius: 12px; padding: 10px 12px; }
.cal-official .kpi2 b { display: block; font: var(--t-montant); }
.cal-official .kpi2 span { font: var(--t-secondaire); color: var(--ink-2); }
.ev .off-ref { font: var(--t-legende); color: var(--ink-3); margin-top: 2px; }
