/* Campus Presence — Espace etudiant (web, PWA et application Android) */

:root {
    --cp-primary: #4f46e5;
    --cp-primary-2: #06b6d4;
    --cp-primary-ink: #ffffff;
    --cp-bg: #f3f5fb;
    --cp-surface: #ffffff;
    --cp-surface-2: #f1f4fa;
    --cp-border: rgba(15, 23, 42, .08);
    --cp-ink: #1e293b;
    --cp-strong: #0f172a;
    --cp-muted: #64748b;
    --cp-ok: #16a34a;
    --cp-ok-soft: #dcfce7;
    --cp-ko: #e11d48;
    --cp-ko-soft: #ffe4e6;
    --cp-warn: #d97706;
    --cp-warn-soft: #fef3c7;
    --cp-info-soft: #e0e7ff;
    --cp-shadow: 0 1px 2px rgba(15, 23, 42, .05), 0 8px 24px rgba(15, 23, 42, .06);
    --cp-radius: 18px;
    --cp-top: 58px;
    --cp-tabbar: 68px;
    --cp-safe-bottom: env(safe-area-inset-bottom, 0px);
    color-scheme: light;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --cp-bg: #0b1120;
        --cp-surface: #121a2c;
        --cp-surface-2: #182237;
        --cp-border: rgba(148, 163, 184, .14);
        --cp-ink: #dbe3ef;
        --cp-strong: #f8fafc;
        --cp-muted: #94a3b8;
        --cp-ok-soft: rgba(22, 163, 74, .18);
        --cp-ko-soft: rgba(225, 29, 72, .18);
        --cp-warn-soft: rgba(217, 119, 6, .2);
        --cp-info-soft: rgba(79, 70, 229, .22);
        --cp-shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 10px 30px rgba(0, 0, 0, .25);
        color-scheme: dark;
    }
}

:root[data-theme="dark"] {
    --cp-bg: #0b1120;
    --cp-surface: #121a2c;
    --cp-surface-2: #182237;
    --cp-border: rgba(148, 163, 184, .14);
    --cp-ink: #dbe3ef;
    --cp-strong: #f8fafc;
    --cp-muted: #94a3b8;
    --cp-ok-soft: rgba(22, 163, 74, .18);
    --cp-ko-soft: rgba(225, 29, 72, .18);
    --cp-warn-soft: rgba(217, 119, 6, .2);
    --cp-info-soft: rgba(79, 70, 229, .22);
    --cp-shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 10px 30px rgba(0, 0, 0, .25);
    color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body { margin: 0; min-height: 100%; background: var(--cp-bg); color: var(--cp-ink); }

body {
    font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", "Noto Naskh Arabic", sans-serif;
    -webkit-font-smoothing: antialiased;
    overscroll-behavior-y: contain;
}

[dir="rtl"] body, [dir="rtl"] { font-family: system-ui, "Noto Naskh Arabic", "Segoe UI", Tahoma, sans-serif; }

a { color: var(--cp-primary); text-decoration: none; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--cp-primary); outline-offset: 2px; border-radius: 6px; }
svg { flex: 0 0 auto; }

.cp-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ------------------------------------------------------------------ Coquille */

.cp-shell { max-width: 960px; margin: 0 auto; min-height: 100dvh; padding-bottom: calc(var(--cp-tabbar) + var(--cp-safe-bottom) + 16px); }

.cp-topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    gap: .6rem;
    height: calc(var(--cp-top) + env(safe-area-inset-top, 0px));
    padding: env(safe-area-inset-top, 0px) 16px 0;
    background: color-mix(in srgb, var(--cp-bg) 86%, transparent);
    backdrop-filter: saturate(1.6) blur(14px);
    -webkit-backdrop-filter: saturate(1.6) blur(14px);
}

.cp-topbar h1 { flex: 1 1 auto; margin: 0; font-size: 1.12rem; font-weight: 750; color: var(--cp-strong); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.cp-icon-btn {
    position: relative;
    display: inline-grid;
    place-items: center;
    width: 40px;
    height: 40px;
    border: 1px solid var(--cp-border);
    border-radius: 12px;
    background: var(--cp-surface);
    color: var(--cp-ink);
    box-shadow: var(--cp-shadow);
}

.cp-icon-btn svg { width: 20px; height: 20px; }
.cp-icon-btn .cp-dot { position: absolute; top: 7px; inset-inline-end: 7px; width: 9px; height: 9px; border-radius: 50%; background: var(--cp-ko); border: 2px solid var(--cp-surface); }

.cp-main { padding: 4px 16px 24px; }

/* ------------------------------------------------------------------ Barre d'onglets */

.cp-tabbar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 30;
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    align-items: end;
    height: calc(var(--cp-tabbar) + var(--cp-safe-bottom));
    padding: 0 6px var(--cp-safe-bottom);
    background: color-mix(in srgb, var(--cp-surface) 92%, transparent);
    backdrop-filter: saturate(1.6) blur(16px);
    -webkit-backdrop-filter: saturate(1.6) blur(16px);
    border-top: 1px solid var(--cp-border);
}

.cp-tab {
    display: grid;
    justify-items: center;
    gap: 3px;
    padding: 9px 0 10px;
    border: 0;
    background: none;
    color: var(--cp-muted);
    font-size: .7rem;
    font-weight: 650;
}

.cp-tab svg { width: 23px; height: 23px; }
.cp-tab[aria-current="page"] { color: var(--cp-primary); }

.cp-tab--scan { position: relative; }
.cp-tab--scan .cp-scan-orb {
    display: grid;
    place-items: center;
    width: 58px;
    height: 58px;
    margin-top: -26px;
    border-radius: 20px;
    background: linear-gradient(135deg, var(--cp-primary), var(--cp-primary-2));
    color: #fff;
    box-shadow: 0 10px 24px color-mix(in srgb, var(--cp-primary) 45%, transparent);
    transition: transform .2s;
}

.cp-tab--scan .cp-scan-orb svg { width: 28px; height: 28px; }
.cp-tab--scan:active .cp-scan-orb { transform: scale(.94); }
.cp-tab--scan.is-live .cp-scan-orb { background: linear-gradient(135deg, #16a34a, #22c55e); animation: cp-pulse 1.6s ease-out infinite; }

@keyframes cp-pulse {
    0% { box-shadow: 0 0 0 0 rgba(34, 197, 94, .55); }
    100% { box-shadow: 0 0 0 18px rgba(34, 197, 94, 0); }
}

@media (min-width: 900px) {
    .cp-tabbar { left: 50%; right: auto; width: 640px; transform: translateX(-50%); bottom: 16px; border-radius: 22px; border: 1px solid var(--cp-border); box-shadow: var(--cp-shadow); height: var(--cp-tabbar); padding-bottom: 0; }
}

/* ------------------------------------------------------------------ Elements */

.cp-card {
    background: var(--cp-surface);
    border: 1px solid var(--cp-border);
    border-radius: var(--cp-radius);
    box-shadow: var(--cp-shadow);
    padding: 16px;
}

.cp-card + .cp-card, .cp-stack > * + * { margin-top: 12px; }
.cp-section-title { display: flex; align-items: baseline; justify-content: space-between; gap: .5rem; margin: 22px 2px 10px; font-size: .78rem; font-weight: 800; letter-spacing: .07em; text-transform: uppercase; color: var(--cp-muted); }
.cp-section-title a { text-transform: none; letter-spacing: 0; font-size: .82rem; }

.cp-hero {
    position: relative;
    overflow: hidden;
    padding: 20px;
    border-radius: 24px;
    color: #fff;
    background: radial-gradient(500px 220px at 100% 0%, rgba(6, 182, 212, .55), transparent 60%), linear-gradient(135deg, #4338ca, #4f46e5 45%, #0e7490);
    box-shadow: 0 16px 40px rgba(79, 70, 229, .3);
}

.cp-hero small { opacity: .85; font-weight: 600; }
.cp-hero h2 { margin: 2px 0 12px; font-size: 1.45rem; line-height: 1.2; }
.cp-hero .cp-hero-meta { display: flex; flex-wrap: wrap; gap: 6px; }
.cp-hero .cp-chip { background: rgba(255, 255, 255, .16); color: #fff; border-color: transparent; }
.cp-hero-art { position: absolute; inset-inline-end: -26px; bottom: -34px; width: 150px; height: 150px; opacity: .22; }

.cp-call {
    display: flex;
    align-items: center;
    gap: 14px;
    width: 100%;
    margin-top: 14px;
    padding: 14px 16px;
    border: 0;
    border-radius: 18px;
    text-align: start;
    color: #052e16;
    background: linear-gradient(135deg, #4ade80, #22c55e);
    box-shadow: 0 10px 26px rgba(34, 197, 94, .35);
    font-weight: 700;
}

.cp-call svg { width: 30px; height: 30px; }
.cp-call small { display: block; font-weight: 600; opacity: .8; }
.cp-call.is-idle { background: var(--cp-surface); color: var(--cp-ink); box-shadow: var(--cp-shadow); border: 1px solid var(--cp-border); }
.cp-call.is-done { background: var(--cp-ok-soft); color: var(--cp-ok); box-shadow: none; }

.cp-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.cp-stat { padding: 12px; border-radius: 16px; background: var(--cp-surface); border: 1px solid var(--cp-border); box-shadow: var(--cp-shadow); }
.cp-stat strong { display: block; font-size: 1.45rem; color: var(--cp-strong); font-variant-numeric: tabular-nums; line-height: 1.1; }
.cp-stat span { font-size: .74rem; color: var(--cp-muted); font-weight: 600; }

.cp-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.cp-tile {
    display: grid;
    gap: 10px;
    padding: 14px;
    border-radius: 18px;
    border: 1px solid var(--cp-border);
    background: var(--cp-surface);
    box-shadow: var(--cp-shadow);
    color: var(--cp-ink);
    text-align: start;
    font-weight: 700;
}

.cp-tile .cp-tile-icon { display: grid; place-items: center; width: 42px; height: 42px; border-radius: 14px; }
.cp-tile .cp-tile-icon svg { width: 22px; height: 22px; }
.cp-tile small { display: block; font-weight: 500; color: var(--cp-muted); font-size: .78rem; }

.cp-chip { display: inline-flex; align-items: center; gap: 4px; padding: 3px 9px; border-radius: 999px; font-size: .74rem; font-weight: 700; background: var(--cp-surface-2); border: 1px solid var(--cp-border); color: var(--cp-muted); white-space: nowrap; }
.cp-chip--ok { background: var(--cp-ok-soft); color: var(--cp-ok); border-color: transparent; }
.cp-chip--ko { background: var(--cp-ko-soft); color: var(--cp-ko); border-color: transparent; }
.cp-chip--warn { background: var(--cp-warn-soft); color: var(--cp-warn); border-color: transparent; }
.cp-chip--info { background: var(--cp-info-soft); color: var(--cp-primary); border-color: transparent; }

.cp-list { display: grid; gap: 10px; }
.cp-row { display: flex; align-items: center; gap: 12px; }
.cp-row-main { flex: 1 1 auto; min-width: 0; }
.cp-row-main strong { display: block; color: var(--cp-strong); }
.cp-row-main span { display: block; font-size: .84rem; color: var(--cp-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cp-time { display: grid; place-items: center; min-width: 58px; padding: 8px 6px; border-radius: 14px; background: var(--cp-surface-2); font-weight: 800; color: var(--cp-strong); font-variant-numeric: tabular-nums; line-height: 1.1; }
.cp-time small { font-weight: 600; font-size: .7rem; color: var(--cp-muted); }

.cp-alert { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: 16px; font-size: .9rem; }
.cp-alert svg { width: 20px; height: 20px; margin-top: 1px; }
.cp-alert--ko { background: var(--cp-ko-soft); color: var(--cp-ko); }
.cp-alert--warn { background: var(--cp-warn-soft); color: var(--cp-warn); }
.cp-alert--info { background: var(--cp-info-soft); color: var(--cp-primary); }
.cp-alert--ok { background: var(--cp-ok-soft); color: var(--cp-ok); }

.cp-bar { height: 8px; border-radius: 999px; background: var(--cp-surface-2); overflow: hidden; display: flex; }
.cp-bar span { height: 100%; }
.cp-legend { display: flex; flex-wrap: wrap; gap: 6px 12px; margin-top: 8px; font-size: .78rem; color: var(--cp-muted); }
.cp-legend i { display: inline-block; width: 9px; height: 9px; border-radius: 3px; margin-inline-end: 4px; }

.cp-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 48px;
    padding: 0 18px;
    border: 0;
    border-radius: 14px;
    background: var(--cp-primary);
    color: var(--cp-primary-ink);
    font-weight: 750;
    box-shadow: 0 8px 20px color-mix(in srgb, var(--cp-primary) 30%, transparent);
}

.cp-btn svg { width: 20px; height: 20px; }
.cp-btn--block { width: 100%; }
.cp-btn--ghost { background: var(--cp-surface); color: var(--cp-ink); border: 1px solid var(--cp-border); box-shadow: none; }
.cp-btn--ok { background: var(--cp-ok); }
.cp-btn--ko { background: var(--cp-ko); }
.cp-btn:disabled { opacity: .55; cursor: not-allowed; }

.cp-field { display: grid; gap: 6px; margin-bottom: 14px; }
.cp-field label { font-size: .85rem; font-weight: 700; color: var(--cp-strong); }
.cp-input {
    width: 100%;
    min-height: 50px;
    padding: 0 14px;
    border-radius: 14px;
    border: 1.5px solid var(--cp-border);
    background: var(--cp-surface);
    font-size: 1rem;
}

.cp-input:focus { border-color: var(--cp-primary); outline: none; box-shadow: 0 0 0 4px color-mix(in srgb, var(--cp-primary) 15%, transparent); }
textarea.cp-input { padding: 12px 14px; min-height: 120px; resize: vertical; line-height: 1.5; }

.cp-empty { display: grid; justify-items: center; gap: 8px; padding: 34px 16px; text-align: center; color: var(--cp-muted); }
.cp-empty svg { width: 46px; height: 46px; opacity: .55; }

.cp-skeleton { border-radius: 16px; height: 78px; background: linear-gradient(90deg, var(--cp-surface-2), var(--cp-surface), var(--cp-surface-2)); background-size: 300% 100%; animation: cp-shimmer 1.3s infinite; }
.cp-skeleton + .cp-skeleton { margin-top: 10px; }

@keyframes cp-shimmer { 0% { background-position: 100% 0; } 100% { background-position: 0 0; } }

.cp-segment { display: flex; padding: 4px; border-radius: 14px; background: var(--cp-surface-2); gap: 4px; margin-bottom: 14px; }
.cp-segment button { flex: 1; min-height: 38px; border: 0; border-radius: 11px; background: transparent; font-weight: 700; color: var(--cp-muted); font-size: .88rem; }
.cp-segment button[aria-pressed="true"] { background: var(--cp-surface); color: var(--cp-strong); box-shadow: var(--cp-shadow); }

/* ------------------------------------------------------------------ Connexion */

.cp-login { min-height: 100dvh; display: grid; align-content: center; gap: 18px; max-width: 440px; margin: 0 auto; padding: 32px 20px calc(32px + var(--cp-safe-bottom)); }
.cp-brand { display: grid; justify-items: center; gap: 10px; text-align: center; }
.cp-logo { width: 84px; height: 84px; border-radius: 26px; box-shadow: 0 16px 40px rgba(79, 70, 229, .35); }
.cp-brand h1 { margin: 0; font-size: 1.6rem; color: var(--cp-strong); }
.cp-brand p { margin: 0; color: var(--cp-muted); }
.cp-or { display: flex; align-items: center; gap: 10px; color: var(--cp-muted); font-size: .8rem; font-weight: 700; text-transform: uppercase; }
.cp-or::before, .cp-or::after { content: ""; flex: 1; height: 1px; background: var(--cp-border); }
.cp-lang-switch { display: flex; justify-content: center; gap: 6px; }

/* ------------------------------------------------------------------ Scanner */

.cp-scanner { position: fixed; inset: 0; z-index: 60; background: #000; display: grid; }
.cp-scanner video, .cp-scanner canvas { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.cp-scanner-frame { position: absolute; left: 50%; top: 46%; width: min(72vw, 300px); aspect-ratio: 1; transform: translate(-50%, -50%); border-radius: 28px; box-shadow: 0 0 0 100vmax rgba(0, 0, 0, .55); }
.cp-scanner-frame::before { content: ""; position: absolute; inset: 0; border-radius: 28px; border: 3px solid rgba(255, 255, 255, .9); mask: conic-gradient(#000 0 25%, transparent 0 50%, #000 0 75%, transparent 0) 0 0 / 100% 100%; }
.cp-scanner-line { position: absolute; left: 10%; right: 10%; height: 3px; border-radius: 3px; background: linear-gradient(90deg, transparent, #22d3ee, transparent); animation: cp-scanline 2s ease-in-out infinite; }

@keyframes cp-scanline { 0%, 100% { top: 12%; } 50% { top: 86%; } }

.cp-scanner-ui { position: absolute; inset: 0; display: flex; flex-direction: column; justify-content: space-between; padding: calc(16px + env(safe-area-inset-top, 0px)) 16px calc(24px + var(--cp-safe-bottom)); color: #fff; pointer-events: none; }
.cp-scanner-ui > * { pointer-events: auto; }
.cp-scanner-ui p { margin: 0; text-align: center; font-weight: 600; text-shadow: 0 1px 6px rgba(0, 0, 0, .6); }
.cp-scanner-bar { display: flex; justify-content: center; gap: 12px; }
.cp-scanner-bar button { min-width: 54px; min-height: 54px; border-radius: 18px; border: 0; background: rgba(255, 255, 255, .16); color: #fff; backdrop-filter: blur(10px); font-weight: 700; padding: 0 16px; }

/* ------------------------------------------------------------------ Resultat de pointage */

.cp-result { display: grid; justify-items: center; gap: 10px; padding: 28px 18px; text-align: center; }
.cp-result h2 { margin: 0; color: var(--cp-strong); }
.cp-result p { margin: 0; color: var(--cp-muted); }
.cp-result-icon { display: grid; place-items: center; width: 96px; height: 96px; border-radius: 50%; }
.cp-result-icon svg { width: 50px; height: 50px; }
.cp-result-icon--ok { background: var(--cp-ok-soft); color: var(--cp-ok); animation: cp-pop .5s cubic-bezier(.2, 1.4, .4, 1); }
.cp-result-icon--ko { background: var(--cp-ko-soft); color: var(--cp-ko); animation: cp-shake .45s; }
.cp-result-icon--wait { background: var(--cp-info-soft); color: var(--cp-primary); }
.cp-result-icon--wait svg { animation: cp-spin 1.2s linear infinite; }

@keyframes cp-pop { 0% { transform: scale(.4); opacity: 0; } 100% { transform: scale(1); opacity: 1; } }
@keyframes cp-shake { 0%, 100% { transform: translateX(0); } 25% { transform: translateX(-8px); } 75% { transform: translateX(8px); } }
@keyframes cp-spin { to { transform: rotate(360deg); } }

.cp-steps { display: grid; gap: 8px; width: 100%; max-width: 340px; margin-top: 8px; text-align: start; }
.cp-step { display: flex; align-items: center; gap: 10px; font-size: .9rem; color: var(--cp-muted); }
.cp-step i { display: grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; background: var(--cp-surface-2); font-style: normal; font-size: .75rem; font-weight: 800; }
.cp-step.is-done { color: var(--cp-ok); }
.cp-step.is-done i { background: var(--cp-ok-soft); }
.cp-step.is-active { color: var(--cp-strong); font-weight: 700; }
.cp-step.is-active i { background: var(--cp-info-soft); color: var(--cp-primary); }

/* ------------------------------------------------------------------ Cours 3D */

.cp-course { position: relative; overflow: hidden; padding: 0; }
.cp-course-cover { position: relative; height: 112px; background: radial-gradient(260px 120px at 85% 10%, rgba(255, 255, 255, .35), transparent 60%), linear-gradient(135deg, var(--accent, #4f46e5), #0e7490); }
.cp-course-cover svg { position: absolute; inset-inline-end: 14px; bottom: -12px; width: 110px; height: 110px; color: rgba(255, 255, 255, .5); }
.cp-course-cover .cp-chip { position: absolute; top: 12px; inset-inline-start: 12px; background: rgba(255, 255, 255, .2); color: #fff; border-color: transparent; }
.cp-course-body { padding: 14px 16px 16px; }
.cp-course-body h3 { margin: 0 0 4px; color: var(--cp-strong); font-size: 1.05rem; }
.cp-course-body p { margin: 0 0 12px; color: var(--cp-muted); font-size: .86rem; }
.cp-ring { width: 46px; height: 46px; transform: rotate(-90deg); }
.cp-ring circle { fill: none; stroke-width: 5; }
.cp-ring .track { stroke: var(--cp-surface-2); }
.cp-ring .value { stroke: var(--cp-primary); stroke-linecap: round; }

/* ------------------------------------------------------------------ Epreuve */

.cp-exam-timer { position: sticky; top: calc(var(--cp-top) + env(safe-area-inset-top, 0px)); z-index: 15; display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 10px 14px; margin: 0 -16px 12px; background: var(--cp-strong); color: var(--cp-bg); font-weight: 800; font-variant-numeric: tabular-nums; }
.cp-exam-timer.is-urgent { background: var(--cp-ko); color: #fff; }
.cp-question { white-space: pre-wrap; }
.cp-photos { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.cp-photos figure { position: relative; margin: 0; width: 84px; height: 84px; border-radius: 12px; overflow: hidden; border: 1px solid var(--cp-border); }
.cp-photos img { width: 100%; height: 100%; object-fit: cover; }
.cp-photos button { position: absolute; top: 4px; inset-inline-end: 4px; width: 24px; height: 24px; border-radius: 50%; border: 0; background: rgba(0, 0, 0, .65); color: #fff; font-size: .9rem; line-height: 1; }
.cp-file-btn { position: relative; overflow: hidden; }
.cp-file-btn input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }

/* ------------------------------------------------------------------ Salon */

.cp-chat { display: flex; flex-direction: column; gap: 8px; padding-bottom: 86px; }
.cp-msg { max-width: 82%; padding: 9px 12px; border-radius: 18px; background: var(--cp-surface); border: 1px solid var(--cp-border); box-shadow: var(--cp-shadow); align-self: flex-start; }
.cp-msg small { display: block; font-size: .72rem; font-weight: 700; color: var(--cp-muted); margin-bottom: 2px; }
.cp-msg p { margin: 0; white-space: pre-wrap; word-break: break-word; }
.cp-msg time { display: block; margin-top: 3px; font-size: .68rem; color: var(--cp-muted); text-align: end; }
.cp-msg.is-me { align-self: flex-end; background: var(--cp-primary); color: #fff; border-color: transparent; }
.cp-msg.is-me small, .cp-msg.is-me time { color: rgba(255, 255, 255, .78); }
.cp-msg.is-staff { border-color: color-mix(in srgb, var(--cp-warn) 50%, transparent); background: var(--cp-warn-soft); }
.cp-msg img { display: block; max-width: 100%; max-height: 260px; border-radius: 12px; margin-top: 6px; }
.cp-composer { position: fixed; left: 0; right: 0; bottom: calc(var(--cp-tabbar) + var(--cp-safe-bottom)); z-index: 25; display: flex; gap: 8px; padding: 10px 12px; background: var(--cp-surface); border-top: 1px solid var(--cp-border); }
.cp-composer .cp-input { min-height: 46px; }
@media (min-width: 900px) { .cp-composer { left: 50%; right: auto; width: 640px; transform: translateX(-50%); bottom: calc(var(--cp-tabbar) + 24px); border-radius: 18px; border: 1px solid var(--cp-border); } }

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

.cp-toast {
    position: fixed;
    left: 50%;
    bottom: calc(var(--cp-tabbar) + var(--cp-safe-bottom) + 14px);
    z-index: 80;
    max-width: calc(100vw - 32px);
    padding: 12px 16px;
    border-radius: 14px;
    background: #0f172a;
    color: #f8fafc;
    font-weight: 600;
    font-size: .9rem;
    box-shadow: 0 16px 40px rgba(2, 6, 23, .35);
    transform: translate(-50%, 160%);
    transition: transform .35s cubic-bezier(.2, .9, .3, 1.2);
}

.cp-toast.is-visible { transform: translate(-50%, 0); }

.cp-sheet-scrim { position: fixed; inset: 0; z-index: 70; background: rgba(2, 6, 23, .45); display: grid; align-items: end; justify-items: center; animation: cp-fade .2s; }
.cp-sheet { width: min(560px, 100%); max-height: 86dvh; overflow-y: auto; padding: 8px 18px calc(22px + var(--cp-safe-bottom)); border-radius: 26px 26px 0 0; background: var(--cp-surface); animation: cp-up .3s cubic-bezier(.2, .9, .3, 1); }
.cp-sheet::before { content: ""; display: block; width: 44px; height: 5px; margin: 6px auto 14px; border-radius: 9px; background: var(--cp-border); }
.cp-sheet h2 { margin: 0 0 12px; color: var(--cp-strong); font-size: 1.15rem; }

@keyframes cp-fade { from { opacity: 0; } }
@keyframes cp-up { from { transform: translateY(40%); opacity: .4; } }

.cp-notif { display: flex; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--cp-border); }
.cp-notif:last-child { border-bottom: 0; }
.cp-notif-icon { flex: none; display: grid; place-items: center; width: 40px; height: 40px; border-radius: 13px; background: var(--cp-info-soft); color: var(--cp-primary); }
.cp-notif-icon svg { width: 20px; height: 20px; }
.cp-notif.is-urgent .cp-notif-icon { background: var(--cp-ok-soft); color: var(--cp-ok); }

.cp-kv { display: grid; grid-template-columns: auto 1fr; gap: 8px 14px; font-size: .92rem; }
.cp-kv dt { color: var(--cp-muted); }
.cp-kv dd { margin: 0; text-align: end; font-weight: 700; color: var(--cp-strong); }

.cp-grade { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 12px; }
.cp-grade div { padding: 10px; border-radius: 12px; background: var(--cp-surface-2); text-align: center; }
.cp-grade small { display: block; font-size: .7rem; color: var(--cp-muted); font-weight: 700; }
.cp-grade strong { font-size: 1.05rem; color: var(--cp-strong); font-variant-numeric: tabular-nums; }
.cp-grade-total { font-size: 1.6rem; font-weight: 850; color: var(--cp-strong); font-variant-numeric: tabular-nums; }

.cp-offline { position: fixed; top: calc(var(--cp-top) + env(safe-area-inset-top, 0px)); left: 50%; transform: translateX(-50%); z-index: 40; padding: 6px 12px; border-radius: 0 0 12px 12px; background: var(--cp-warn); color: #1c1100; font-size: .78rem; font-weight: 800; }

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

/* ------------------------------------------------------------------ Espace enseignant */

.cp-mode-switch { margin-bottom: 0; }
.cp-mode-switch button { display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.cp-link { color: inherit; }
.cp-link:active { transform: scale(.99); }
.cp-link.is-live { border-color: rgba(22, 163, 74, .45); box-shadow: 0 0 0 3px rgba(22, 163, 74, .12), var(--cp-shadow); }
a.cp-call { text-decoration: none; }
button.cp-call { width: 100%; border: 0; text-align: start; font: inherit; }

.cp-stats--4 { grid-template-columns: repeat(2, 1fr); margin-top: 12px; }
@media (min-width: 560px) { .cp-stats--4 { grid-template-columns: repeat(4, 1fr); } }

.cp-actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; }
.cp-actions .cp-btn { flex: 1 1 calc(50% - 8px); min-width: 0; }
.cp-actions .cp-btn--wide { flex-basis: 100%; min-height: 54px; font-size: 1.02rem; }

.cp-avatar { display: grid; place-items: center; width: 42px; height: 42px; flex: 0 0 auto; border-radius: 14px; background: var(--cp-info-soft); color: var(--cp-primary); font-weight: 800; font-size: .86rem; }
.cp-avatar--lg { width: 58px; height: 58px; border-radius: 20px; font-size: 1.2rem; background: linear-gradient(135deg, var(--cp-primary), var(--cp-primary-2)); color: #fff; }
.cp-avatar--present { background: var(--cp-ok-soft); color: var(--cp-ok); }
.cp-avatar--late { background: var(--cp-warn-soft); color: var(--cp-warn); }
.cp-avatar--absent { background: var(--cp-ko-soft); color: var(--cp-ko); }
.cp-avatar--justified { background: var(--cp-info-soft); color: var(--cp-primary); }

.cp-att { padding: 12px; }
.cp-participation { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 38px; padding: 0 9px; border: 1px solid var(--cp-border); border-radius: 12px; background: var(--cp-surface); color: var(--cp-muted); font-size: .7rem; font-weight: 750; white-space: nowrap; }
.cp-participation.is-on { background: var(--cp-ok-soft); color: var(--cp-ok); border-color: transparent; }
.cp-participation__check { display: grid; place-items: center; width: 18px; height: 18px; border: 1px solid currentColor; border-radius: 5px; font-size: .75rem; line-height: 1; }
.cp-speciality-group { display: grid; gap: 8px; margin-bottom: 10px; }
.cp-speciality-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; padding: 8px 11px; border-radius: 11px; background: var(--cp-info-soft); color: var(--cp-primary); font-size: .84rem; }
.cp-speciality-heading span { font-size: .72rem; font-weight: 650; white-space: nowrap; }
.cp-pick { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-top: 10px; }
.cp-pick button { min-height: 36px; border-radius: 11px; border: 1px solid var(--cp-border); background: var(--cp-surface-2); color: var(--cp-muted); font-weight: 700; font-size: .8rem; }
.cp-pick button[aria-pressed="true"] { color: #fff; border-color: transparent; }
.cp-pick .cp-pick--present[aria-pressed="true"] { background: var(--cp-ok); }
.cp-pick .cp-pick--late[aria-pressed="true"] { background: var(--cp-warn); }
.cp-pick .cp-pick--absent[aria-pressed="true"] { background: var(--cp-ko); }
.cp-pick .cp-pick--justified[aria-pressed="true"] { background: var(--cp-primary); }
.cp-gps-override { width: 100%; min-height: 42px; margin-top: 8px; font-size: .82rem; }

/* QR affiche sur le telephone de l'enseignant */
.cp-qr-screen { display: grid; justify-items: center; gap: 12px; text-align: center; }
.cp-qr-head { display: grid; gap: 2px; }
.cp-qr-head strong { font-size: 1.1rem; color: var(--cp-strong); }
.cp-qr-head span { color: var(--cp-muted); font-size: .86rem; }
.cp-qr-box { padding: 14px; border: 0; border-radius: 26px; background: #fff; box-shadow: 0 18px 50px rgba(15, 23, 42, .18); line-height: 0; }
.cp-qr-box img { display: block; width: min(calc(100vw - 72px), 52dvh, 420px); height: auto; aspect-ratio: 1; image-rendering: pixelated; }
.cp-qr-box[hidden], .cp-qr-closed[hidden], .cp-qr-timer[hidden] { display: none; }
.cp-qr-closed { display: grid; justify-items: center; gap: 6px; width: min(80vw, 420px); padding: 34px 18px; border-radius: 26px; border: 2px dashed var(--cp-border); color: var(--cp-muted); }
.cp-qr-closed strong { color: var(--cp-strong); font-size: 1.05rem; }
.cp-qr-timer { display: inline-flex; align-items: center; gap: 10px; font-weight: 700; color: var(--cp-muted); }
.cp-qr-ring { position: relative; display: grid; place-items: center; width: 40px; height: 40px; }
.cp-qr-ring svg { position: absolute; inset: 0; transform: rotate(-90deg); }
.cp-qr-ring circle { fill: none; stroke: var(--cp-surface-2); stroke-width: 3.5; }
.cp-qr-ring circle + circle { stroke: var(--cp-primary-2); stroke-linecap: round; stroke-dasharray: 97.4; transition: stroke-dashoffset 1s linear; }
.cp-qr-ring b { font-size: .9rem; color: var(--cp-strong); font-variant-numeric: tabular-nums; }
.cp-qr-count { display: flex; align-items: baseline; gap: 8px; font-weight: 700; color: var(--cp-muted); }
.cp-qr-count strong { font-size: 2.6rem; line-height: 1; color: var(--cp-ok); font-variant-numeric: tabular-nums; }
.cp-qr-count.is-bump strong { animation: cp-pop .5s cubic-bezier(.2, 1.4, .4, 1); }
.cp-qr-screen .cp-actions { width: 100%; max-width: 520px; }
.cp-qr-hint { max-width: 440px; margin: 0; color: var(--cp-muted); font-size: .8rem; }

/* Plein ecran : le QR occupe tout l'ecran, barre et onglets masques */
body.cp-presenting .cp-topbar, body.cp-presenting .cp-tabbar, body.cp-presenting .cp-qr-head,
body.cp-presenting .cp-qr-screen .cp-actions, body.cp-presenting .cp-qr-hint { display: none; }
body.cp-presenting .cp-shell { padding-bottom: 0; }
body.cp-presenting .cp-main { min-height: 100dvh; display: grid; align-content: center; }
body.cp-presenting .cp-qr-box img { width: min(calc(100vw - 60px), 78dvh); }

/* Statistiques */
.cp-kpis { display: grid; gap: 10px; }
@media (min-width: 560px) { .cp-kpis { grid-template-columns: 1fr 1fr; } }
.cp-kpis .cp-card + .cp-card { margin-top: 0; }
.cp-kpi { display: flex; align-items: center; gap: 14px; }
.cp-kpi small { position: absolute; font-weight: 800; font-size: .68rem; }
.cp-kpi strong { display: block; font-size: 1.4rem; color: var(--cp-strong); }
.cp-kpi .cp-row-main span { color: var(--cp-muted); font-size: .84rem; }
.cp-chart { display: flex; align-items: flex-end; gap: 6px; height: 150px; }
.cp-chart-col { flex: 1; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 4px; min-width: 0; }
.cp-chart-bar { width: 100%; max-width: 34px; border-radius: 8px 8px 4px 4px; }
.cp-chart-bar.is-empty { background: var(--cp-surface-2) !important; }
.cp-chart-value { font-size: .7rem; font-weight: 800; color: var(--cp-strong); }
.cp-chart-col small { font-size: .64rem; color: var(--cp-muted); white-space: nowrap; }
.cp-card .cp-hero-meta { display: flex; flex-wrap: wrap; gap: 6px; }

/* Mise a jour de l'application Android */
.cp-update { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; border-color: rgba(79, 70, 229, .35); background: linear-gradient(135deg, var(--cp-info-soft), var(--cp-surface)); }
.cp-update .cp-row-main span { display: block; color: var(--cp-muted); font-size: .82rem; }
.cp-update-icon { display: grid; place-items: center; width: 42px; height: 42px; flex: 0 0 auto; border-radius: 14px; background: var(--cp-primary); color: #fff; }
.cp-update .cp-btn { flex: 0 0 auto; }
.cp-update .cp-row-main span { white-space: normal; overflow: visible; }

/* Messages des enseignants a une specialite */
.cp-check { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border: 1px solid var(--cp-border); border-radius: 14px; background: var(--cp-surface); cursor: pointer; }
.cp-check input { flex: none; width: 22px; height: 22px; margin: 0; accent-color: var(--cp-primary); }
.cp-check > span { display: grid; gap: 2px; min-width: 0; }
.cp-check small { color: var(--cp-muted); font-size: .8rem; }
.cp-check:has(input:checked) { border-color: var(--cp-primary); background: var(--cp-info-soft); }
.cp-check:has(input:disabled) { opacity: .55; cursor: default; }
.cp-hint { margin: 0 2px; color: var(--cp-muted); font-size: .86rem; }
.cp-announce h3 { margin: 0 0 6px; font-size: 1.05rem; color: var(--cp-strong); }
.cp-announce p { margin: 0 0 10px; white-space: pre-wrap; word-break: break-word; line-height: 1.55; }
.cp-announce > small { display: block; margin-top: 10px; color: var(--cp-muted); font-size: .78rem; }
.cp-announce.is-unread { border-color: var(--cp-primary); box-shadow: inset 0 0 0 1px var(--cp-primary), var(--cp-shadow); }
.cp-announce.is-important { border-inline-start: 4px solid var(--cp-warn); }
.cp-announce-img { display: block; max-width: 100%; max-height: 320px; border-radius: 12px; }
.cp-announce-teaser { margin-top: 12px; }
.cp-announce-teaser.is-important .cp-notif-icon { background: var(--cp-warn-soft); color: var(--cp-warn); }

/* Alertes d'absences et participation */
.cp-notif[data-type="absences"] .cp-notif-icon { background: var(--cp-ko-soft); color: var(--cp-ko); }
.cp-notif[data-type="participation"] .cp-notif-icon { background: var(--cp-ok-soft); color: var(--cp-ok); }
.cp-part-row { width: 100%; text-align: start; font: inherit; color: inherit; cursor: pointer; }
.cp-part-row.is-on { border-color: color-mix(in srgb, var(--cp-ok) 45%, transparent); background: color-mix(in srgb, var(--cp-ok-soft) 55%, var(--cp-surface)); }

/* Bandeau flottant (message, appel ouvert) quand l'application est ouverte */
.cp-banner { position: fixed; top: calc(env(safe-area-inset-top, 0px) + 8px); left: 10px; right: 10px; z-index: 90; display: flex; align-items: flex-start; gap: 12px; padding: 12px 12px 12px 14px; border-radius: 18px; background: var(--cp-surface); border: 1px solid var(--cp-border); box-shadow: 0 12px 40px rgba(15, 23, 42, .22); cursor: pointer; transform: translateY(calc(-100% - 20px)); opacity: 0; transition: transform .25s ease, opacity .25s ease; }
.cp-banner.is-visible { transform: translateY(0); opacity: 1; }
.cp-banner .cp-row-main span { white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.cp-banner small { display: block; margin-top: 2px; color: var(--cp-primary); font-weight: 700; font-size: .75rem; }
.cp-banner.is-urgent { border-color: color-mix(in srgb, var(--cp-ok) 55%, transparent); }
.cp-banner.is-urgent .cp-notif-icon { background: var(--cp-ok-soft); color: var(--cp-ok); }
.cp-banner[data-type="absences"] .cp-notif-icon { background: var(--cp-ko-soft); color: var(--cp-ko); }
.cp-banner-close { flex: none; display: grid; place-items: center; width: 32px; height: 32px; border: 0; border-radius: 10px; background: transparent; color: var(--cp-muted); }
@media (min-width: 900px) { .cp-banner { left: auto; right: 24px; width: 380px; } }

/* Corrige de fin d'epreuve */
.cp-correction-part { margin-top: 10px; padding: 10px 12px; border-radius: 12px; background: var(--cp-bg); }
.cp-correction-part small { display: block; font-size: .72rem; font-weight: 800; letter-spacing: .04em; text-transform: uppercase; color: var(--cp-muted); margin-bottom: 4px; }
.cp-correction-part.is-key { background: var(--cp-ok-soft); }
.cp-correction-part.is-key small { color: var(--cp-ok); }
.cp-correction-part .cp-question { margin: 0; }
.cp-correction .cp-photos img { display: block; width: 96px; height: 96px; object-fit: cover; border-radius: 12px; border: 1px solid var(--cp-border); }

/* Calculatrice integree a l'epreuve */
.cp-calc-fab { position: fixed; right: 14px; bottom: calc(var(--cp-tabbar) + var(--cp-safe-bottom) + 14px); z-index: 30; display: inline-flex; align-items: center; gap: 8px; padding: 12px 16px; border: 0; border-radius: 999px; background: var(--cp-primary); color: #fff; font-weight: 750; box-shadow: 0 10px 28px rgba(79, 70, 229, .35); }
.cp-calc-screen { padding: 12px 14px; border-radius: 14px; background: var(--cp-bg); text-align: right; font-variant-numeric: tabular-nums; }
.cp-calc-screen div { min-height: 1.4em; color: var(--cp-muted); font-size: .95rem; overflow-wrap: anywhere; }
.cp-calc-screen strong { display: block; font-size: 1.9rem; color: var(--cp-strong); overflow-wrap: anywhere; }
.cp-calc-keys { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 12px; }
.cp-calc-key { min-height: 52px; border: 1px solid var(--cp-border); border-radius: 14px; background: var(--cp-surface); color: var(--cp-strong); font-size: 1.15rem; font-weight: 650; }
.cp-calc-key:active { transform: scale(.96); }
.cp-calc-key.is-op { background: var(--cp-info-soft); color: var(--cp-primary); }
.cp-calc-key.is-eq { background: var(--cp-primary); color: #fff; border-color: transparent; }
.cp-calc-key.is-clear { color: var(--cp-ko); }

/*
 * Petits ecrans et texte agrandi (police systeme Android « grande ») : rien ne deborde
 * de l'ecran. Les grilles et les lignes laissent retrecir leur contenu, les textes longs
 * passent a la ligne ou se terminent par « … ».
 */
.cp-main { min-width: 0; max-width: 100%; }
.cp-list, .cp-kpis { grid-template-columns: minmax(0, 1fr); }
.cp-grid { grid-template-columns: repeat(auto-fill, minmax(min(150px, 100%), 1fr)); }
.cp-stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.cp-stats--4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (min-width: 560px) { .cp-stats--4 { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.cp-tabbar { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.cp-list > *, .cp-stack > *, .cp-kpis > *, .cp-grid > *, .cp-stats > *, .cp-actions > *, .cp-row > *, .cp-kpi > * { min-width: 0; }
.cp-card, .cp-stat, .cp-tile { max-width: 100%; overflow-wrap: break-word; }
.cp-row-main strong, .cp-stat span, .cp-tile { overflow-wrap: break-word; }
.cp-time, .cp-avatar, .cp-notif-icon, .cp-kpi > :first-child { flex: none; }
.cp-btn { max-width: 100%; white-space: normal; text-align: center; line-height: 1.2; padding-top: 8px; padding-bottom: 8px; overflow-wrap: break-word; }
/* Boutons d'action : chacun prend la largeur de son texte, les rangees se remplissent. */
.cp-actions .cp-btn { flex: 1 1 auto; padding-left: 12px; padding-right: 12px; }
.cp-btn svg { flex: none; }
.cp-chip { max-width: 100%; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.cp-pick { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.cp-pick button { min-width: 0; padding: 0 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* Ligne d'un etudiant : si la place manque, « Participation » passe sous le nom. */
.cp-att .cp-row, .cp-part-row { flex-wrap: wrap; row-gap: 8px; }
.cp-att .cp-row-main, .cp-part-row .cp-row-main { flex: 1 1 9rem; }
.cp-participation { flex: none; margin-inline-start: auto; white-space: nowrap; }
.cp-participation__check { flex: none; }
.cp-tab { min-width: 0; }
.cp-tab span:not(.cp-scan-orb) { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cp-segment { overflow-x: auto; scrollbar-width: none; }
.cp-segment button { white-space: nowrap; }
.cp-section-title { gap: 8px; overflow-wrap: break-word; }

/* Camera integree de l'epreuve (photo prise sans quitter l'application) */
.cp-camera { position: fixed; inset: 0; z-index: 90; display: flex; flex-direction: column; background: #000; }
.cp-camera video { flex: 1 1 auto; min-height: 0; width: 100%; object-fit: contain; background: #000; }
.cp-camera-bar { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 12px; padding: 16px 18px calc(18px + var(--cp-safe-bottom)); background: #000; }
.cp-camera-bar .cp-btn { justify-self: start; color: #fff; border-color: rgba(255, 255, 255, .4); }
.cp-camera-shot { width: 74px; height: 74px; border-radius: 50%; border: 5px solid #fff; background: rgba(255, 255, 255, .85); box-shadow: 0 0 0 3px rgba(0, 0, 0, .4) inset; }
.cp-camera-shot:active { transform: scale(.92); background: #fff; }

/* Epreuve a ecran epingle : enonce couvert tant que l'ecran n'est pas epingle */
.cp-pin-guard { position: fixed; inset: 0; z-index: 95; display: flex; align-items: center; justify-content: center; padding: 16px; background: var(--cp-bg); color: var(--cp-ink); overflow-y: auto; }
.cp-pin-guard[hidden] { display: none; }
.cp-pin-box { max-width: 420px; width: 100%; text-align: center; display: flex; flex-direction: column; gap: 12px; align-items: center; }
.cp-pin-box h2 { margin: 0; font-size: 1.25rem; }
.cp-pin-box p { margin: 0; line-height: 1.5; overflow-wrap: anywhere; }
.cp-pin-box .cp-btn { width: 100%; }

/* Notes : partie pas encore autorisee par l'enseignant */
.cp-grade div.is-waiting { opacity: .75; border: 1px dashed var(--cp-border); background: transparent; }
