/* ==========================================================================
   Akademika — feuille de style
   Identité : vert malachite (espace professeurs) et cuivre (espace parents).
   Signature : le bandeau d'en-tête aux veines concentriques, comme une pierre
   de malachite polie. Le reste reste sobre et lisible en plein soleil.
   ========================================================================== */

:root {
    /* Encre et papier */
    --ink:        #17231f;
    --ink-2:      #3c4a45;
    --muted:      #66756f;
    --faint:      #97a39e;
    --paper:      #eef1ee;
    --surface:    #ffffff;
    --sunk:       #f5f7f5;
    --line:       #dfe5e1;
    --line-soft:  #edf1ee;

    /* Marque (professeurs par défaut) */
    --brand:       #0e6b54;
    --brand-deep:  #08483a;
    --brand-tint:  #e3f1ec;
    --brand-ink:   #0a5442;

    /* Accent */
    --copper:      #a65a26;
    --copper-tint: #f6e9df;

    /* États */
    --good:      #1d7a45;
    --good-bg:   #e2f3e8;
    --mid:       #9a6200;
    --mid-bg:    #fbefd6;
    --low:       #b3261e;
    --low-bg:    #fbe4e2;

    /* Typo */
    --font-display: "Bricolage Grotesque", "Segoe UI Variable Display", "Segoe UI", system-ui, sans-serif;
    --font-body: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;

    /* Formes */
    --r-lg: 18px;
    --r-md: 12px;
    --r-sm: 8px;
    --shadow: 0 1px 0 rgba(23, 35, 31, .04), 0 1px 3px rgba(23, 35, 31, .06);
    --shadow-up: 0 -6px 24px rgba(23, 35, 31, .08);

    /* Gabarits */
    --topbar-h: 58px;
    --nav-h: 64px;
    --safe-b: env(safe-area-inset-bottom, 0px);
}

.role-parent {
    --brand:       #8a4a1e;
    --brand-deep:  #5b2f12;
    --brand-tint:  #f6ebe2;
    --brand-ink:   #6e3a16;
    --copper:      #0e6b54;   /* l'accent s'inverse : une touche de malachite chez les parents */
    --copper-tint: #e3f1ec;
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: calc(var(--topbar-h) + 12px); }
body {
    font-family: var(--font-body);
    font-size: 15px;
    line-height: 1.5;
    color: var(--ink);
    background: var(--paper);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    padding-bottom: calc(var(--nav-h) + var(--safe-b) + 16px);
}
body.auth { padding-bottom: 0; }
a { color: var(--brand-ink); text-decoration: none; }
img, svg { display: block; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--brand) 55%, transparent); outline-offset: 2px; border-radius: 6px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
[hidden] { display: none !important; }

.ico { width: 20px; height: 20px; flex-shrink: 0; }
.muted { color: var(--muted); }
.mono-num { font-variant-numeric: tabular-nums; letter-spacing: .01em; }
.link { font-size: .875rem; font-weight: 600; color: var(--brand-ink); white-space: nowrap; }
.count {
    display: inline-block; min-width: 1.6em; padding: 0 .45em; margin-left: .25em;
    border-radius: 999px; background: var(--line-soft); color: var(--muted);
    font: 600 .75rem/1.6 var(--font-body); text-align: center; vertical-align: .15em;
}

.tone-good { color: var(--good); }
.tone-mid  { color: var(--mid); }
.tone-low  { color: var(--low); }
.tone-neutral { color: var(--muted); }

/* ---------- Bandeau (signature) ---------- */
.topbar,
.hero {
    background-color: var(--brand-deep);
    background-image:
        repeating-radial-gradient(ellipse at 108% -30%, rgba(255,255,255,.075) 0 1.5px, transparent 1.5px 11px),
        repeating-radial-gradient(ellipse at -20% 140%, rgba(255,255,255,.05) 0 1px, transparent 1px 14px);
    color: #fff;
}
/* Le héros part de la teinte profonde du bandeau pour éviter toute couture */
.hero {
    background-image:
        repeating-radial-gradient(ellipse at 108% -30%, rgba(255,255,255,.075) 0 1.5px, transparent 1.5px 11px),
        repeating-radial-gradient(ellipse at -20% 140%, rgba(255,255,255,.05) 0 1px, transparent 1px 14px),
        linear-gradient(180deg, var(--brand-deep) 0%, var(--brand) 160%);
}
.topbar {
    position: sticky; top: 0; z-index: 50;
    height: var(--topbar-h);
    display: flex; align-items: center; justify-content: space-between;
    padding: env(safe-area-inset-top, 0px) 16px 0;
    box-sizing: content-box;
}
.brand { display: flex; align-items: center; gap: 10px; color: #fff; }
.brand-mark {
    width: 32px; height: 32px; border-radius: 10px;
    display: grid; place-items: center;
    background: rgba(255,255,255,.14);
    box-shadow: inset 0 0 0 1px rgba(255,255,255,.22);
    font: 700 1.05rem/1 var(--font-display);
}
.brand-mark-lg {
    width: 52px; height: 52px; border-radius: 15px; font-size: 1.6rem;
    background: var(--brand); color: #fff; box-shadow: none;
}
.brand-text { font: 700 1.08rem/1.05 var(--font-display); letter-spacing: -.01em; }
.brand-text small { display: block; font: 500 .72rem/1.3 var(--font-body); opacity: .75; letter-spacing: 0; }

.avatar-btn { border-radius: 999px; padding: 2px; }
.avatar-btn .avatar { background: rgba(255,255,255,.16); color: #fff; box-shadow: inset 0 0 0 1px rgba(255,255,255,.3); }

/* Le héros prolonge le bandeau sur les accueils */
.hero {
    margin: -16px -16px 22px;
    padding: 6px 20px 22px;
    border-radius: 0 0 26px 26px;
}
.hero-date { font-size: .85rem; opacity: .8; }
.hero-title {
    font: 700 clamp(1.7rem, 7vw, 2.2rem)/1.1 var(--font-display);
    letter-spacing: -.02em; margin: 2px 0 16px;
}
.hero-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.hero-stats > div {
    background: rgba(255,255,255,.1);
    border-radius: var(--r-md);
    padding: 10px 12px;
    box-shadow: inset 0 0 0 1px rgba(255,255,255,.12);
}
.hero-stats dt { font-size: .75rem; opacity: .8; }
.hero-stats dd { font: 700 1.45rem/1.15 var(--font-display); font-variant-numeric: tabular-nums; }
.hero-stats dd small { font: 500 .75rem var(--font-body); opacity: .75; margin-left: 2px; }

/* ---------- Avatar ---------- */
.avatar {
    width: 38px; height: 38px; border-radius: 999px;
    display: inline-grid; place-items: center; flex-shrink: 0;
    background: var(--brand-tint); color: var(--brand-ink);
    font: 700 .82rem/1 var(--font-display); letter-spacing: .02em;
}
.avatar-sm { width: 32px; height: 32px; font-size: .72rem; }
.avatar-lg { width: 46px; height: 46px; font-size: .95rem; }
.avatar-xl { width: 64px; height: 64px; font-size: 1.3rem; }

/* ---------- Mise en page ---------- */
.app-main { max-width: 760px; margin: 0 auto; padding: 16px; }

.page-head { margin: 4px 0 18px; }
.page-head-row { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; }
.page-title {
    font: 700 1.6rem/1.15 var(--font-display);
    letter-spacing: -.015em; color: var(--ink);
    overflow-wrap: anywhere;
}
.lede { color: var(--muted); font-size: .92rem; margin-top: 4px; }
.back {
    display: inline-flex; align-items: center; gap: 2px;
    margin: 0 0 10px -6px; padding: 6px 8px 6px 2px;
    font-size: .88rem; font-weight: 600; color: var(--brand-ink);
    border-radius: var(--r-sm);
}
.back .ico { width: 18px; height: 18px; }
.page-head .back { display: flex; width: fit-content; }

.block { margin-bottom: 26px; }
.block-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.block-title { font: 700 1.05rem/1.3 var(--font-display); color: var(--ink); margin-bottom: 10px; }
.block-head .block-title { margin-bottom: 0; }
.block-title.with-avatar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.block-title.with-avatar small { font: 500 .82rem var(--font-body); }

/* ---------- Surfaces ---------- */
.panel { background: var(--surface); border-radius: var(--r-lg); box-shadow: var(--shadow); }
.row-list { overflow: hidden; }
.row {
    display: flex; align-items: center; gap: 12px;
    padding: 12px 14px; color: inherit;
    border-top: 1px solid var(--line-soft);
    min-height: 56px;
}
.row:first-child { border-top: 0; }
a.row:active { background: var(--sunk); }
.row-body { flex: 1; min-width: 0; display: block; }
.row-title { display: block; font-weight: 600; font-size: .95rem; line-height: 1.3; overflow-wrap: anywhere; }
.row-sub { display: block; font-size: .83rem; color: var(--muted); margin-top: 1px; }
.row-meta { display: block; font-size: .76rem; color: var(--faint); margin-top: 3px; }
.row-trail { font: 700 .95rem var(--font-display); font-variant-numeric: tabular-nums; color: var(--ink-2); white-space: nowrap; }
.row-ico {
    width: 38px; height: 38px; border-radius: 11px; flex-shrink: 0;
    display: grid; place-items: center;
    background: var(--brand-tint); color: var(--brand-ink);
}
.row-chevron { color: var(--faint); width: 18px; height: 18px; }
.row-alert .row-ico { background: var(--mid-bg); color: var(--mid); }
.clamp-2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

.card-stack { display: flex; flex-direction: column; gap: 10px; }

.item-card {
    background: var(--surface); border-radius: var(--r-lg); box-shadow: var(--shadow);
    padding: 14px 16px;
}
.item-card.is-past { opacity: .72; }
.item-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.item-title { font: 700 1rem/1.3 var(--font-display); overflow-wrap: anywhere; }
.item-sub { font-size: .83rem; color: var(--muted); margin-top: 2px; }
.item-text { font-size: .9rem; color: var(--ink-2); margin-top: 10px; overflow-wrap: anywhere; }
.item-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 12px; flex-wrap: wrap; }
.item-actions { display: flex; align-items: center; gap: 6px; }
.due { display: inline-flex; align-items: center; gap: 6px; font-size: .84rem; color: var(--ink-2); }
.due .ico { width: 16px; height: 16px; color: var(--faint); }
.due small { color: var(--muted); }
.due.tone-mid, .due.tone-mid .ico { color: var(--mid); }

/* ---------- Pastilles ---------- */
.chip {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 3px 10px; border-radius: 999px;
    font-size: .76rem; font-weight: 600; white-space: nowrap;
    background: var(--line-soft); color: var(--ink-2);
}
.chip-good { background: var(--good-bg); color: var(--good); }
.chip-mid  { background: var(--mid-bg);  color: var(--mid); }
.chip-low  { background: var(--low-bg);  color: var(--low); }
.chip-neutral { background: var(--line-soft); color: var(--muted); }
.chip-xs { font-size: .68rem; padding: 1px 7px; margin-top: 3px; }

/* ---------- Jauges ---------- */
.meter { height: 6px; border-radius: 999px; background: var(--line-soft); overflow: hidden; margin-top: 8px; }
.meter > span { display: block; height: 100%; border-radius: inherit; background: var(--brand); transition: width .5s ease; }
.meter-good > span { background: var(--good); }
.meter-mid  > span { background: #d18b0b; }
.meter-low  > span { background: var(--low); }
.meter-light { background: rgba(255,255,255,.2); height: 8px; }
.meter-light > span { background: #fff; }

/* ---------- Boutons ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    min-height: 42px; padding: 0 16px;
    border-radius: var(--r-md); border: 1px solid transparent;
    font-size: .92rem; font-weight: 600; line-height: 1.1;
    text-align: center; white-space: nowrap;
    transition: background-color .15s, transform .1s;
}
.btn:active { transform: scale(.98); }
.btn .ico { width: 18px; height: 18px; }
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-deep); }
.btn-ghost { background: var(--surface); color: var(--ink-2); border-color: var(--line); }
.btn-ghost:hover { background: var(--sunk); }
.btn-danger { background: transparent; color: var(--low); }
.btn-danger:hover { background: var(--low-bg); }
.btn-sm { min-height: 36px; padding: 0 12px; font-size: .84rem; border-radius: 10px; }
.btn-sm.btn-danger { padding: 0 9px; }
.btn-lg { min-height: 52px; font-size: 1rem; border-radius: 14px; }
.btn-block { display: flex; width: 100%; }
.btn[disabled] { opacity: .65; pointer-events: none; }
.inline-form { display: inline; }

/* ---------- Raccourcis ---------- */
.shortcut-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.shortcut-grid-4 { grid-template-columns: repeat(4, 1fr); }
.shortcut {
    display: flex; flex-direction: column; align-items: flex-start; justify-content: space-between; gap: 14px;
    min-height: 88px; padding: 12px;
    background: var(--surface); border-radius: var(--r-md); box-shadow: var(--shadow);
    color: var(--ink); font-size: .83rem; font-weight: 600; line-height: 1.2;
}
.shortcut .ico { width: 22px; height: 22px; color: var(--brand); }
.shortcut:active { transform: scale(.98); }
.shortcut.is-primary { background: var(--brand); color: #fff; }
.shortcut.is-primary .ico { color: #fff; }
.shortcut-grid-4 .shortcut { align-items: center; text-align: center; min-height: 78px; gap: 8px; justify-content: center; }

/* ---------- Agenda ---------- */
.agenda { list-style: none; display: flex; flex-direction: column; gap: 8px; }
.slot {
    display: flex; align-items: center; gap: 14px;
    background: var(--surface); border-radius: var(--r-md); box-shadow: var(--shadow);
    padding: 12px 14px;
}
.slot-time { display: flex; flex-direction: column; min-width: 48px; font-variant-numeric: tabular-nums; }
.slot-time strong { font: 700 1.05rem/1.1 var(--font-display); }
.slot-time span { font-size: .78rem; color: var(--muted); }
.slot-body { flex: 1; min-width: 0; padding-left: 14px; border-left: 2px solid var(--line); }
.slot-title { font-weight: 600; line-height: 1.3; }
.slot-meta { display: flex; align-items: center; flex-wrap: wrap; gap: 4px; font-size: .82rem; color: var(--muted); margin-top: 2px; }
.slot-meta .ico { width: 14px; height: 14px; }
.slot-meta .sep { width: 3px; height: 3px; border-radius: 50%; background: var(--faint); margin: 0 4px; }
.slot .chip { margin-top: 6px; }
.slot.is-now { box-shadow: inset 0 0 0 2px var(--brand), var(--shadow); }
.slot.is-now .slot-body { border-left-color: var(--brand); }
.slot.is-done { opacity: .6; }

.day-tabs { display: flex; gap: 6px; overflow-x: auto; padding: 2px 2px 6px; margin-bottom: 12px; scrollbar-width: none; }
.day-tabs::-webkit-scrollbar { display: none; }
.day-tab {
    display: flex; flex-direction: column; align-items: center; min-width: 54px;
    padding: 8px 10px; border-radius: var(--r-md);
    background: var(--surface); box-shadow: var(--shadow);
    font-weight: 700; font-size: .88rem;
}
.day-tab small { font-weight: 500; font-size: .72rem; color: var(--muted); }
.day-tab.is-today { box-shadow: inset 0 0 0 1.5px var(--brand); }
.day-tab.is-active { background: var(--brand); color: #fff; }
.day-tab.is-active small { color: rgba(255,255,255,.8); }
.tab-panel .block-title { display: flex; align-items: center; gap: 8px; }
.day-pill {
    width: 42px; height: 42px; border-radius: 11px; display: grid; place-items: center;
    background: var(--sunk); font-weight: 700; font-size: .82rem; flex-shrink: 0;
}
.day-pill.is-today { background: var(--brand); color: #fff; }

/* ---------- Cours ---------- */
.course-card {
    display: block; padding: 16px; color: inherit;
    background: var(--surface); border-radius: var(--r-lg); box-shadow: var(--shadow);
    border-left: 4px solid var(--brand);
}
.course-code {
    display: inline-block; font-size: .75rem; font-weight: 700; color: var(--copper);
    background: var(--copper-tint); padding: 2px 8px; border-radius: 6px; margin-bottom: 6px;
}
.course-name { font: 700 1.15rem/1.25 var(--font-display); }
.course-promo { font-size: .86rem; color: var(--muted); margin-top: 2px; }
.course-facts { display: flex; gap: 22px; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line-soft); }
.course-facts dt { font-size: .74rem; color: var(--muted); }
.course-facts dd { font: 700 1.05rem var(--font-display); font-variant-numeric: tabular-nums; }

/* ---------- Métriques ---------- */
.metrics { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin-bottom: 20px; }
.metrics-3 { grid-template-columns: repeat(3, 1fr); }
.metric { background: var(--surface); border-radius: var(--r-md); box-shadow: var(--shadow); padding: 12px 14px; }
.metric-value { display: block; font: 700 1.5rem/1.15 var(--font-display); font-variant-numeric: tabular-nums; }
.metric-label { display: block; font-size: .78rem; color: var(--muted); margin-top: 2px; line-height: 1.3; }

.score { font: 700 1.15rem/1 var(--font-display); font-variant-numeric: tabular-nums; white-space: nowrap; }
.score small { font: 500 .72rem var(--font-body); color: var(--muted); margin-left: 1px; }
.score-lg { font-size: 1.6rem; }

/* ---------- États vides, encarts ---------- */
.empty-state {
    display: flex; flex-direction: column; align-items: center; text-align: center; gap: 10px;
    padding: 28px 20px; border-radius: var(--r-lg);
    border: 1.5px dashed var(--line); color: var(--muted); font-size: .92rem;
}
.empty-state .ico { width: 30px; height: 30px; color: var(--faint); }
.empty-state p { max-width: 34ch; }
.callout {
    display: flex; gap: 10px; align-items: flex-start;
    background: var(--brand-tint); color: var(--brand-ink);
    border-radius: var(--r-md); padding: 12px 14px; margin-bottom: 18px; font-size: .88rem;
}
.callout .ico { margin-top: 1px; }
.callout a { font-weight: 700; text-decoration: underline; text-underline-offset: 2px; }
.hint { display: block; font-size: .8rem; color: var(--muted); margin-top: 6px; }
.filter-empty { padding: 16px; color: var(--muted); font-size: .88rem; text-align: center; }

/* ---------- Messages ---------- */
.toast {
    display: flex; align-items: flex-start; gap: 10px;
    padding: 12px 12px 12px 14px; margin-bottom: 16px;
    border-radius: var(--r-md); font-size: .9rem; font-weight: 500;
    animation: toast-in .25s ease-out;
}
.toast > span { flex: 1; padding-top: 1px; }
.toast-success { background: var(--good-bg); color: var(--good); }
.toast-error { background: var(--low-bg); color: var(--low); }
.toast-close { color: inherit; opacity: .6; padding: 2px; border-radius: 6px; }
.toast-close .ico { width: 18px; height: 18px; }
.toast.is-leaving { opacity: 0; transform: translateY(-6px); transition: .25s; }
@keyframes toast-in { from { opacity: 0; transform: translateY(-6px); } }

/* ---------- Formulaires ---------- */
.form {
    background: var(--surface); border-radius: var(--r-lg); box-shadow: var(--shadow);
    padding: 18px 16px;
}
.field { margin-bottom: 16px; min-width: 0; }
.field > label, .scale legend {
    display: block; font-size: .86rem; font-weight: 600; color: var(--ink-2); margin-bottom: 6px;
}
.optional { font-weight: 400; color: var(--faint); margin-left: 4px; }
.field input:not([type="file"]):not([type="radio"]),
.field select,
.field textarea,
.search input {
    width: 100%; min-height: 46px; padding: 10px 12px;
    border: 1.5px solid var(--line); border-radius: var(--r-md);
    background-color: var(--surface);
    font-size: 1rem; /* 16 px : évite le zoom automatique sur iOS */
    transition: border-color .15s, box-shadow .15s;
}
.field textarea { resize: vertical; min-height: 96px; }
.field select {
    appearance: none; -webkit-appearance: none; padding-right: 38px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2366756f' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 12px center; background-size: 18px;
}
.field input:focus, .field select:focus, .field textarea:focus, .search input:focus, .grade-input:focus {
    outline: none; border-color: var(--brand);
    box-shadow: 0 0 0 4px color-mix(in srgb, var(--brand) 16%, transparent);
}
.field select:disabled { background-color: var(--sunk); color: var(--faint); }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.scale { border: 0; }
.form-actions { margin-top: 6px; }

.input-affix { position: relative; }
.input-affix input { padding-right: 48px !important; }
.affix-btn {
    position: absolute; right: 4px; top: 50%; transform: translateY(-50%);
    width: 40px; height: 40px; display: grid; place-items: center; border-radius: 10px; color: var(--muted);
}

.file-drop {
    display: flex; align-items: center; gap: 10px;
    padding: 14px; border: 1.5px dashed var(--line); border-radius: var(--r-md);
    color: var(--muted); font-size: .9rem; cursor: pointer; position: relative; overflow: hidden;
}
.file-drop input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.file-drop:focus-within { border-color: var(--brand); }
.file-drop.has-file { border-style: solid; border-color: var(--brand); color: var(--brand-ink); background: var(--brand-tint); }
.file-drop-lg { flex-direction: column; justify-content: center; padding: 26px 14px; text-align: center; }
.file-drop-lg .ico { width: 26px; height: 26px; }
.file-drop span { overflow-wrap: anywhere; }

.search { position: relative; display: block; margin-bottom: 10px; flex: 1; }
.search .ico { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); width: 18px; height: 18px; color: var(--faint); }
.search input { padding-left: 38px; }

.toolbar { display: flex; gap: 8px; align-items: flex-start; }
.toolbar .btn { min-height: 46px; }

/* Résumés collants (appel et cotation) */
.sticky-summary {
    position: sticky; top: calc(var(--topbar-h) + env(safe-area-inset-top, 0px)); z-index: 20;
    display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px;
    background: color-mix(in srgb, var(--paper) 92%, transparent);
    -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
    margin: 0 -16px 12px; padding: 10px 16px;
    border-bottom: 1px solid var(--line);
}
.sticky-summary > div { display: flex; align-items: baseline; gap: 5px; flex-wrap: wrap; }
.sum-value { font: 700 1.35rem/1 var(--font-display); font-variant-numeric: tabular-nums; }
.sum-label { font-size: .74rem; color: var(--muted); line-height: 1.2; }

.sticky-actions {
    position: sticky; bottom: calc(var(--nav-h) + var(--safe-b) + 8px); z-index: 20;
    margin-top: 14px;
}
.sticky-actions .btn { box-shadow: 0 8px 22px color-mix(in srgb, var(--brand) 35%, transparent); }

/* Appel : bascule P / A */
.att-row { padding: 10px 12px; }
.att-time {
    border: 0; background: transparent; color: var(--muted);
    font-size: .8rem; padding: 0 0 0 6px; width: auto; min-height: 0;
}
.att-row:not(:has(input[value="present"]:checked)) .att-time { display: none; }
.seg { display: flex; background: var(--sunk); border-radius: 12px; padding: 3px; gap: 3px; flex-shrink: 0; position: relative; }
.seg input { position: absolute; opacity: 0; pointer-events: none; width: 1px; height: 1px; }
.seg label {
    width: 44px; height: 40px; display: grid; place-items: center;
    border-radius: 9px; font: 700 .95rem var(--font-display); color: var(--faint);
    cursor: pointer; transition: background-color .12s, color .12s;
    -webkit-tap-highlight-color: transparent;
}
.seg input:focus-visible + label { outline: 3px solid color-mix(in srgb, var(--brand) 55%, transparent); }
.seg input:checked + .seg-present { background: var(--good); color: #fff; }
.seg input:checked + .seg-absent  { background: var(--low); color: #fff; }
.att-row:has(input[value="absent"]:checked) .row-title { color: var(--low); }

/* Cotation */
.grade-row { cursor: text; }
.grade-field { display: flex; align-items: center; gap: 4px; flex-shrink: 0; }
.grade-input {
    width: 72px; min-height: 44px; padding: 8px;
    border: 1.5px solid var(--line); border-radius: 10px;
    text-align: center; font: 700 1.05rem var(--font-display); font-variant-numeric: tabular-nums;
    background: var(--surface); -moz-appearance: textfield; appearance: textfield;
}
.grade-input::-webkit-outer-spin-button, .grade-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.grade-input.is-filled { background: var(--brand-tint); border-color: transparent; }
.grade-input.is-low { color: var(--low); }
.grade-input.is-invalid { border-color: var(--low); background: var(--low-bg); }
.grade-input-sm { width: 64px; min-height: 38px; font-size: .95rem; }
.grade-max { font-size: .8rem; color: var(--faint); min-width: 22px; }

/* Étapes (bulletins) */
.steps { list-style: none; display: flex; gap: 6px; margin-bottom: 16px; }
.steps li {
    flex: 1; display: flex; align-items: center; gap: 6px;
    font-size: .8rem; font-weight: 600; color: var(--faint);
    padding-top: 8px; border-top: 3px solid var(--line);
}
.steps span {
    width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center;
    background: var(--line); color: var(--muted); font-size: .72rem;
}
.steps .is-done { color: var(--muted); border-top-color: var(--brand); }
.steps .is-done span { background: var(--brand-tint); color: var(--brand-ink); }
.steps .is-current { color: var(--ink); border-top-color: var(--brand); }
.steps .is-current span { background: var(--brand); color: #fff; }

/* Tableau (prévisualisation des moyennes) */
.table-wrap {
    overflow-x: auto; -webkit-overflow-scrolling: touch;
    background: var(--surface); border-radius: var(--r-lg); box-shadow: var(--shadow);
}
.table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: .86rem; }
.table th, .table td { padding: 10px; text-align: left; border-bottom: 1px solid var(--line-soft); white-space: nowrap; }
.table thead th { font-size: .76rem; font-weight: 600; color: var(--muted); background: var(--sunk); }
.table thead th small { display: block; font-weight: 400; color: var(--faint); }
.table tbody tr:last-child > * { border-bottom: 0; }
.table .num { text-align: center; font-variant-numeric: tabular-nums; }
.table-sticky th:first-child {
    position: sticky; left: 0; z-index: 1; background: var(--surface);
    box-shadow: 1px 0 0 var(--line-soft); max-width: 46vw;
}
.table-sticky thead th:first-child { background: var(--sunk); }
.table tbody th { font-weight: 600; }
.cell-name { display: block; overflow: hidden; text-overflow: ellipsis; }

/* Fichiers */
.file-badge {
    width: 42px; height: 42px; border-radius: 10px; flex-shrink: 0;
    display: grid; place-items: center;
    background: var(--copper-tint); color: var(--copper);
    font: 700 .66rem var(--font-display); letter-spacing: .02em;
}

/* Dépliants */
.fold > summary {
    list-style: none; cursor: pointer; display: flex; align-items: center; gap: 6px;
    padding: 6px 0; margin-bottom: 8px;
}
.fold > summary::-webkit-details-marker { display: none; }
.fold > summary::after {
    content: ""; width: 7px; height: 7px; margin-left: 4px;
    border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted);
    transform: rotate(45deg) translateY(-2px); transition: transform .2s;
}
.fold[open] > summary::after { transform: rotate(-135deg) translateY(-2px); }
.fold:not(.block) > summary { font-size: .88rem; font-weight: 600; color: var(--muted); margin-top: 10px; }
.fold-inline > summary { font-size: .84rem; color: var(--brand-ink); margin: 8px 0 0; }

/* ---------- Espace parents ---------- */
.child-card {
    background: var(--surface); border-radius: var(--r-lg); box-shadow: var(--shadow);
    padding: 14px;
}
.child-head { display: flex; align-items: center; gap: 12px; color: inherit; }
.child-head > div { flex: 1; min-width: 0; }
.child-name { font: 700 1.1rem/1.2 var(--font-display); }
.child-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-top: 14px; }
.child-stats > div {
    background: var(--sunk); border-radius: var(--r-md); padding: 10px 8px;
    display: flex; flex-direction: column; gap: 1px; color: var(--ink); min-width: 0;
}
.child-stats dt { font-size: .72rem; color: var(--muted); }
.child-stats dd { font: 700 1.2rem/1.15 var(--font-display); font-variant-numeric: tabular-nums; }
.child-stats dd small { font: 500 .66rem var(--font-body); color: var(--muted); }
.child-stats > div > span { font-size: .7rem; color: var(--muted); line-height: 1.25; overflow-wrap: anywhere; }
.child-stats > .tone-good dd, .child-stats > .tone-good > span { color: var(--good); }
.child-stats > .tone-mid  dd, .child-stats > .tone-mid  > span { color: var(--mid); }
.child-stats > .tone-low  dd, .child-stats > .tone-low  > span { color: var(--low); }

.recent-grades { margin-top: 12px; }
.mini-title { font-size: .78rem; color: var(--muted); margin-bottom: 4px; }
.recent-grades ul { list-style: none; }
.recent-grades li {
    display: flex; justify-content: space-between; gap: 10px;
    padding: 6px 0; border-top: 1px solid var(--line-soft); font-size: .88rem;
}
.recent-grades li:first-child { border-top: 0; }
.recent-grades strong { font: 700 .95rem var(--font-display); font-variant-numeric: tabular-nums; }
.child-actions { display: flex; gap: 8px; margin-top: 12px; }
.child-actions .btn { flex: 1; }

.period-card {
    background: var(--surface); border-radius: var(--r-lg); box-shadow: var(--shadow);
    margin-bottom: 12px; overflow: hidden;
}
.period-card > summary {
    list-style: none; cursor: pointer;
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    padding: 14px 16px;
}
.period-card > summary::-webkit-details-marker { display: none; }
.period-card[open] > summary { border-bottom: 1px solid var(--line-soft); }
.period-name { font: 700 1.05rem/1.25 var(--font-display); }
.grade-bars { list-style: none; padding: 6px 16px 14px; }
.grade-bars li { padding: 10px 0; border-top: 1px solid var(--line-soft); }
.grade-bars li:first-child { border-top: 0; }
.gb-head { display: flex; align-items: baseline; gap: 8px; }
.gb-name { flex: 1; font-weight: 600; font-size: .92rem; min-width: 0; overflow-wrap: anywhere; }
.gb-raw { font-size: .78rem; color: var(--faint); font-variant-numeric: tabular-nums; }
.gb-head strong { font: 700 1.05rem var(--font-display); font-variant-numeric: tabular-nums; min-width: 2.6em; text-align: right; }
.grade-bars .meter { margin-top: 6px; }

.timeline { list-style: none; padding-left: 4px; }
.timeline li { display: flex; gap: 14px; padding: 8px 0; position: relative; }
.timeline li::before { content: ""; position: absolute; left: 6px; top: 0; bottom: 0; width: 2px; background: var(--line); }
.timeline li:first-child::before { top: 18px; }
.timeline li:last-child::before { bottom: calc(100% - 18px); }
.tl-dot { width: 14px; height: 14px; border-radius: 50%; margin-top: 4px; flex-shrink: 0; position: relative; box-shadow: 0 0 0 3px var(--paper); }
.is-present .tl-dot { background: var(--good); }
.is-absent .tl-dot { background: var(--low); }
.timeline .is-absent .row-title { color: var(--low); }

.profile { display: flex; align-items: center; gap: 14px; }
.facts { padding: 4px 16px; }
.facts > div { display: flex; justify-content: space-between; gap: 16px; padding: 11px 0; border-top: 1px solid var(--line-soft); font-size: .9rem; }
.facts > div:first-child { border-top: 0; }
.facts dt { color: var(--muted); flex-shrink: 0; }
.facts dd { font-weight: 600; text-align: right; overflow-wrap: anywhere; }

.prose { padding: 18px 16px; font-size: 1rem; line-height: 1.65; color: var(--ink-2); max-width: 70ch; overflow-wrap: anywhere; }

/* Frais */
.fee-hero {
    background: var(--brand-deep);
    background-image: linear-gradient(150deg, var(--brand), var(--brand-deep));
    color: #fff; border-radius: var(--r-lg); padding: 16px; margin-bottom: 10px;
}
.fee-hero-top { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.fee-hero-top span { font-size: .86rem; opacity: .85; }
.fee-hero-top strong { font: 700 1.5rem/1.1 var(--font-display); font-variant-numeric: tabular-nums; }
.fee-hero-foot { display: flex; justify-content: space-between; gap: 12px; font-size: .8rem; opacity: .85; margin-top: 8px; }
.fee-card { border-left: 4px solid var(--line); }
.tone-edge-good { border-left-color: var(--good); }
.tone-edge-mid  { border-left-color: #d18b0b; }
.tone-edge-low  { border-left-color: var(--low); }
.fee-figures { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 12px; }
.fee-figures dt { font-size: .74rem; color: var(--muted); }
.fee-figures dd { font: 700 .98rem var(--font-display); font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.fee-card .row-meta { margin-top: 10px; }
.deposits { list-style: none; margin-top: 6px; }
.deposits li {
    display: flex; justify-content: space-between; align-items: center; gap: 10px;
    padding: 8px 0; border-top: 1px solid var(--line-soft); font-size: .86rem;
}
.deposits small { display: block; color: var(--faint); font-size: .74rem; }
.deposits strong { color: var(--good); font-variant-numeric: tabular-nums; white-space: nowrap; }

/* ---------- Navigation basse ---------- */
.bottom-nav {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 60;
    display: flex; justify-content: center;
    height: calc(var(--nav-h) + var(--safe-b)); padding-bottom: var(--safe-b);
    background: var(--surface); box-shadow: var(--shadow-up);
}
.nav-item {
    flex: 1; max-width: 120px;
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
    color: var(--muted); font-size: .7rem; font-weight: 600; position: relative;
    -webkit-tap-highlight-color: transparent;
}
.nav-item .ico { width: 23px; height: 23px; }
.nav-item.is-active { color: var(--brand); }
.nav-item.is-active::before {
    content: ""; position: absolute; top: 0; width: 28px; height: 3px;
    border-radius: 0 0 3px 3px; background: var(--brand);
}

/* ---------- Feuilles (modules, compte) ---------- */
.sheet { position: fixed; inset: 0; z-index: 100; }
.sheet-backdrop { position: absolute; inset: 0; background: rgba(15, 25, 22, .45); animation: fade .2s; }
.sheet-panel {
    position: absolute; left: 0; right: 0; bottom: 0;
    max-width: 560px; margin: 0 auto;
    background: var(--surface); border-radius: 22px 22px 0 0;
    padding: 8px 18px calc(22px + var(--safe-b));
    animation: rise .25s cubic-bezier(.2,.8,.3,1);
    max-height: 85vh; overflow-y: auto;
}
.sheet-handle { width: 40px; height: 4px; border-radius: 4px; background: var(--line); margin: 4px auto 14px; }
.sheet-title { font: 700 1.15rem/1.25 var(--font-display); margin-bottom: 14px; }
.sheet-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.sheet-link {
    display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center;
    padding: 14px 6px; border-radius: var(--r-md); background: var(--sunk);
    color: var(--ink); font-size: .8rem; font-weight: 600; line-height: 1.2;
}
.sheet-ico {
    width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center;
    background: var(--surface); color: var(--brand); box-shadow: var(--shadow);
}
.sheet-link.is-active { background: var(--brand-tint); color: var(--brand-ink); }
.account-head { display: flex; align-items: center; gap: 14px; margin-bottom: 18px; }
.account-head .sheet-title { margin-bottom: 0; }
body.sheet-open { overflow: hidden; }
@keyframes rise { from { transform: translateY(100%); } }
@keyframes fade { from { opacity: 0; } }

/* ---------- Connexion & erreurs ---------- */
body.auth {
    background-color: var(--brand-deep);
    background-image:
        repeating-radial-gradient(ellipse at 100% 0%, rgba(255,255,255,.07) 0 1.5px, transparent 1.5px 13px),
        repeating-radial-gradient(ellipse at 0% 100%, rgba(255,255,255,.05) 0 1px, transparent 1px 17px),
        linear-gradient(160deg, var(--brand) 0%, var(--brand-deep) 75%);
    background-attachment: fixed;
}
body.auth .app-main, .auth-wrap { max-width: 440px; margin: 0 auto; }
.auth-wrap { min-height: calc(100vh - 32px); display: flex; flex-direction: column; justify-content: center; padding: 24px 16px; }
body.auth .app-main .auth-wrap { padding: 24px 0; }
.auth-card {
    background: var(--surface); border-radius: 24px;
    padding: 26px 22px 22px; box-shadow: 0 24px 60px rgba(0,0,0,.25);
}
.auth-brand { display: flex; align-items: center; gap: 14px; margin-bottom: 24px; }
.auth-title { font: 700 1.7rem/1.1 var(--font-display); letter-spacing: -.02em; }
.auth-code { font: 700 3.5rem/1 var(--font-display); color: var(--brand); margin-bottom: 8px; }
.auth-card .lede + .btn { margin-top: 20px; }
.auth-foot { font-size: .8rem; color: var(--muted); text-align: center; margin-top: 18px; }
body.auth .toast { margin-top: 16px; }

/* ---------- Écrans plus larges ---------- */
@media (min-width: 640px) {
    .app-main { padding: 24px; }
    .hero { margin: -24px -24px 24px; padding: 12px 28px 28px; }
    .shortcut-grid { grid-template-columns: repeat(6, 1fr); }
    .shortcut-grid-4 { grid-template-columns: repeat(4, 1fr); }
    .metrics-4 { grid-template-columns: repeat(4, 1fr); }
    .sticky-summary { margin: 0 -24px 12px; padding: 10px 24px; }
}
@media (max-width: 380px) {
    .shortcut-grid, .shortcut-grid-4 { grid-template-columns: repeat(2, 1fr); }
    .child-stats { grid-template-columns: repeat(2, 1fr); }
    .metrics-3 { grid-template-columns: 1fr 1fr; }
    .field-row { grid-template-columns: 1fr; gap: 0; }
    .hero-stats dd { font-size: 1.2rem; }
    .seg label { width: 40px; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation: none !important; transition: none !important; }
}
