:root {
    --v2-ink: var(--gx-encre, #30343d);
    --v2-muted: var(--gx-encre-douce, #62666e);
    --v2-bg: #fff9e8;
    --v2-paper: rgba(255, 255, 255, 0.94);
    --v2-border: #eadcae;
    --v2-teal: var(--gx-action, #0b756a);
    --v2-teal-bright: var(--gx-app-fasteval, #12a997);
    --v2-coral: #f15f49;
    --v2-purple: var(--gx-app-schoolmonsters, #7541a8);
    --v2-yellow: var(--gx-app-clicetmots, #d99300);
    --v2-danger: var(--gx-erreur, #8a2f2a);
    --v2-shadow: 0 18px 50px rgba(79, 65, 22, 0.14), 0 3px 10px rgba(79, 65, 22, 0.08);
    --v2-shadow-soft: 0 8px 24px rgba(79, 65, 22, 0.1);
    --v2-radius-lg: 24px;
    --v2-radius-md: 16px;
    color: var(--v2-ink);
    font-family: Lexend, "Segoe UI", sans-serif;
    background: var(--v2-bg);
}

* { box-sizing: border-box; }

html { min-width: 320px; scroll-behavior: smooth; }

body {
    margin: 0;
    min-height: 100vh;
    color: var(--v2-ink);
    background:
        radial-gradient(circle at 15% 8%, rgba(255, 222, 92, 0.22), transparent 28rem),
        radial-gradient(circle at 88% 82%, rgba(18, 169, 151, 0.1), transparent 30rem),
        var(--v2-bg);
}

body::before {
    position: fixed;
    inset: 0;
    z-index: -1;
    content: "";
    pointer-events: none;
    opacity: 0.18;
    background-image:
        linear-gradient(115deg, transparent 48%, rgba(218, 171, 37, 0.18) 49%, transparent 50%),
        radial-gradient(circle, rgba(218, 171, 37, 0.22) 1px, transparent 1px);
    background-size: 180px 180px, 32px 32px;
    mask-image: linear-gradient(to bottom, #000, transparent 85%);
}

button, input, select { font: inherit; }
a { color: inherit; }
img { max-width: 100%; }
[hidden] { display: none !important; }

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.skip-link {
    position: fixed;
    top: 8px;
    left: 8px;
    z-index: 100;
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    padding: 10px 14px;
    border-radius: 10px;
    color: #fff;
    background: var(--v2-teal);
    transform: translateY(-150%);
}

.skip-link:focus { transform: translateY(0); }

:focus-visible {
    outline: 3px solid #075fbd;
    outline-offset: 3px;
}

.brand img { display: block; width: 100%; height: auto; }

.preview-badge {
    display: inline-flex;
    align-items: center;
    min-height: 28px;
    padding: 5px 10px;
    border: 1px solid rgba(11, 117, 106, 0.25);
    border-radius: 999px;
    color: var(--v2-teal);
    background: #ecf8f5;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.03em;
    text-transform: uppercase;
}

.eyebrow {
    margin: 0 0 8px;
    color: var(--v2-teal);
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

/* Connexion */
.login-layout {
    width: min(1080px, calc(100% - 32px));
    margin: 0 auto;
    padding: 34px 0 24px;
}

.brand-login {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 18px;
    margin-bottom: 24px;
}

.brand-login img {
    display: block;
    width: min(500px, 88vw);
    height: auto;
    margin: 0 auto;
}

.login-card {
    display: grid;
    grid-template-columns: minmax(280px, 0.9fr) minmax(380px, 1.1fr);
    overflow: hidden;
    border: 1px solid var(--v2-border);
    border-radius: var(--v2-radius-lg);
    background: var(--v2-paper);
    box-shadow: var(--v2-shadow);
}

.login-intro {
    position: relative;
    padding: clamp(34px, 5vw, 60px);
    border-right: 1px solid #eee6cd;
    background: linear-gradient(145deg, #fffdf7, #fff8e4);
}

.login-intro::after {
    position: absolute;
    top: 38px;
    right: 30px;
    content: "➤";
    color: #efb21d;
    font-size: 2.2rem;
    transform: rotate(-28deg);
}

.login-intro h1 {
    margin: 0;
    font-size: clamp(2rem, 4vw, 3rem);
    line-height: 1.12;
    letter-spacing: -0.04em;
}

.intro-copy {
    max-width: 28ch;
    margin: 22px 0 32px;
    color: var(--v2-muted);
    font-size: 1.05rem;
    line-height: 1.65;
}

.benefits {
    display: grid;
    gap: 18px;
    padding: 0;
    margin: 0;
    list-style: none;
}

.benefits li {
    display: flex;
    align-items: center;
    gap: 14px;
    line-height: 1.45;
}

.benefit-icon {
    display: grid;
    flex: 0 0 52px;
    width: 52px;
    height: 52px;
    place-items: center;
    border-radius: 50%;
    color: var(--v2-teal);
    background: #fff4ca;
    font-size: 1.5rem;
    font-weight: 700;
}

.login-form-panel { padding: clamp(34px, 5vw, 60px); }

.login-form-panel h2 {
    margin: 0 0 26px;
    font-size: clamp(1.7rem, 3vw, 2.2rem);
    letter-spacing: -0.035em;
}

.alert {
    display: grid;
    gap: 3px;
    padding: 12px 15px;
    margin: 0 0 18px;
    border: 1px solid #e8d092;
    border-radius: 12px;
    color: #725314;
    background: #fff8df;
    font-size: 0.9rem;
}

.alert-error {
    border-color: #ebc6c2;
    color: var(--v2-danger);
    background: #fff2f0;
}

.role-picker { padding: 0; margin: 0 0 20px; border: 0; }
.role-picker legend, .field > label { margin-bottom: 8px; font-weight: 600; }

.role-options { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.role-option { cursor: pointer; }
.role-option input { position: absolute; opacity: 0; pointer-events: none; }

.role-option > span {
    display: flex;
    box-sizing: border-box;
    height: 56px;
    align-items: center;
    justify-content: flex-start;
    min-height: 56px;
    gap: 10px;
    padding: 8px 14px;
    border: 1px solid #d6d0c0;
    border-radius: 12px;
    background: #fff;
    transition: border-color 160ms ease, background 160ms ease, box-shadow 160ms ease;
}

.role-option b { display: none; margin-left: auto; }
.role-option input:checked + span {
    border: 2px solid var(--v2-teal-bright);
    color: var(--v2-teal);
    background: #eef9f7;
    box-shadow: inset 0 0 0 1px rgba(18, 169, 151, 0.08);
}
.role-option input:checked + span b {
    display: grid;
    width: 24px;
    height: 24px;
    place-items: center;
    border-radius: 50%;
    color: #fff;
    background: var(--v2-teal-bright);
    font-size: 0.75rem;
}
.role-option-teacher input:checked + span {
    border-color: #d89a10;
    color: #715000;
    background: #fff8e7;
    box-shadow: inset 0 0 0 1px rgba(216, 154, 16, 0.08);
}
.role-option-teacher input:checked + span b { background: #d89a10; }
.role-option input:focus-visible + span { outline: 3px solid #075fbd; outline-offset: 3px; }
.role-symbol {
    display: grid;
    width: 34px;
    height: 34px;
    flex: 0 0 34px;
    place-items: center;
    border-radius: 10px;
}
.role-symbol svg {
    width: 21px;
    height: 21px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}
.role-symbol-student { color: #087f73; background: #ddf5f1; }
.role-symbol-teacher { color: #8c6100; background: #fff0bf; }

.field { display: grid; margin: 0 0 18px; }
.field input, .field select {
    width: 100%;
    min-height: 52px;
    padding: 12px 15px;
    border: 1px solid #ccc5b3;
    border-radius: 11px;
    color: var(--v2-ink);
    background: #fff;
}
.field input:hover, .field select:hover { border-color: #9c9480; }
.field input:focus, .field select:focus { border-color: var(--v2-teal-bright); box-shadow: 0 0 0 3px rgba(18, 169, 151, 0.14); outline: none; }
.field input::placeholder { color: #858992; }

.password-field { position: relative; }
.password-field input { padding-right: 54px; }
.password-toggle {
    position: absolute;
    top: 4px;
    right: 4px;
    display: grid;
    width: 44px;
    height: 44px;
    place-items: center;
    border: 0;
    border-radius: 9px;
    color: var(--v2-muted);
    background: transparent;
    cursor: pointer;
}
.password-toggle:hover { color: var(--v2-teal); background: #eef9f7; }

.primary-button {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-height: 54px;
    gap: 12px;
    padding: 12px 20px;
    border: 0;
    border-radius: 12px;
    color: #fff;
    background: linear-gradient(135deg, var(--v2-teal), #0c9183);
    box-shadow: 0 8px 18px rgba(11, 117, 106, 0.22);
    font-weight: 700;
    cursor: pointer;
    transition: transform 160ms ease, box-shadow 160ms ease;
}
.primary-button:hover { transform: translateY(-1px); box-shadow: 0 10px 22px rgba(11, 117, 106, 0.28); }
.primary-button:active { transform: translateY(0); }
.login-help { margin: 16px 0 0; color: var(--v2-muted); font-size: 0.85rem; text-align: center; }
.legacy-link { margin: 20px 0 0; color: var(--v2-muted); font-size: 0.85rem; text-align: center; }
.legacy-link a:hover { color: var(--v2-teal); }

/* Tableau de bord */
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 86px;
    padding: 12px max(24px, calc((100vw - 1440px) / 2));
    border-bottom: 1px solid var(--v2-border);
    background: rgba(255, 255, 255, 0.9);
    box-shadow: 0 3px 14px rgba(79, 65, 22, 0.06);
    backdrop-filter: blur(12px);
}
.brand-dashboard { display: inline-flex; min-height: 44px; align-items: center; padding: 2px 4px; border-radius: 10px; }
.brand-dashboard img { width: auto; height: 60px; margin: -6px 0; }
.topbar-actions { display: flex; align-items: center; gap: 12px; }
.user-menu { position: relative; }
.user-menu summary {
    display: flex;
    align-items: center;
    min-height: 50px;
    gap: 10px;
    padding: 5px 12px 5px 6px;
    border: 1px solid var(--v2-border);
    border-radius: 14px;
    background: #fffdfa;
    cursor: pointer;
    list-style: none;
}
.user-menu summary::-webkit-details-marker { display: none; }
.user-avatar {
    display: grid;
    width: 38px;
    height: 38px;
    place-items: center;
    border-radius: 50%;
    color: var(--v2-teal);
    background: #fff0b7;
    font-weight: 700;
}
.user-texte { display: flex; flex-direction: column; align-items: flex-start; line-height: 1.25; }
.user-texte strong { max-width: 220px; overflow: hidden; font-size: 0.9rem; text-overflow: ellipsis; white-space: nowrap; }
.user-role { padding: 1px 9px; border-radius: 999px; color: #8a5a06; background: #fdeecb; font-size: 0.68rem; font-weight: 700; letter-spacing: 0.03em; text-transform: uppercase; }
.user-popover {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    z-index: 20;
    display: grid;
    min-width: 235px;
    overflow: hidden;
    border: 1px solid var(--v2-border);
    border-radius: 14px;
    background: #fff;
    box-shadow: var(--v2-shadow-soft);
}
.user-popover span { padding: 13px 15px; color: var(--v2-muted); background: #fffaf0; font-size: 0.78rem; }
.user-popover a { padding: 13px 15px; text-decoration: none; }
.user-popover a:hover { background: #f5f5ef; }
.user-popover .logout-link { color: var(--v2-danger); border-top: 1px solid #eee8d8; }

.dashboard { width: min(1440px, calc(100% - 48px)); margin: 0 auto; padding: clamp(38px, 6vw, 72px) 0 30px; }
.dashboard-heading { margin-bottom: 28px; }
.dashboard-heading h1 { margin: 0; font-size: clamp(2.2rem, 5vw, 3.6rem); line-height: 1.05; letter-spacing: -0.045em; }
.dashboard-heading > p:last-child { margin: 12px 0 0; color: var(--v2-muted); font-size: clamp(1rem, 2vw, 1.35rem); }
.dashboard-alert { max-width: 720px; }
.dashboard-grid { display: block; }

.app-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); align-content: stretch; gap: 18px; }
.app-card {
    display: grid;
    grid-template-columns: 104px 1fr auto;
    align-items: center;
    min-height: 150px;
    gap: 16px;
    padding: 16px 18px;
    border: 1px solid var(--v2-border);
    border-left-width: 4px;
    border-radius: var(--v2-radius-md);
    background: var(--v2-paper);
    box-shadow: var(--v2-shadow-soft);
    text-decoration: none;
    transition: transform 160ms ease, box-shadow 160ms ease;
}
.app-card:hover { transform: translateY(-3px); box-shadow: var(--v2-shadow); }
.app-logo { display: grid; width: 104px; height: 64px; place-items: center; }
.app-logo img { display: block; max-width: 100px; max-height: 60px; object-fit: contain; }
.app-card strong { display: block; font-size: clamp(1.1rem, 1.7vw, 1.4rem); }
.app-card small { display: block; margin-top: 7px; color: var(--v2-muted); line-height: 1.35; }
.app-card b { font-size: 2.5rem; font-weight: 400; }
.app-card.games strong, .app-card.games b { color: var(--v2-coral); }
.app-card.fast strong, .app-card.fast b { color: var(--v2-teal); }
.app-card.school strong, .app-card.school b { color: var(--v2-purple); }
.app-card.clic strong, .app-card.clic b { color: var(--v2-yellow); }
.app-card.fast { border-left-color: var(--v2-teal-bright); }
.app-card.school { border-left-color: var(--v2-purple); }
.app-card.clic { border-left-color: var(--v2-yellow); }
.app-card.games { border-left-color: var(--v2-coral); }
.dashboard-footer { display: flex; justify-content: space-between; gap: 20px; padding: 20px 4px 0; color: var(--v2-muted); font-size: 0.82rem; }
.dashboard-footer a { display: inline-flex; align-items: center; min-height: 44px; }
.dashboard-footer a:hover { color: var(--v2-teal); }

/* État de déconnexion */
.logout-page { display: grid; place-items: center; padding: 24px; }
.system-card { max-width: 480px; padding: 38px; border: 1px solid var(--v2-border); border-radius: var(--v2-radius-lg); background: #fff; box-shadow: var(--v2-shadow); text-align: center; }
.system-card h1 { margin: 18px 0 8px; font-size: 1.6rem; }
.system-card p { margin: 0; color: var(--v2-muted); }
.spinner { display: inline-block; width: 42px; height: 42px; border: 4px solid #d5ede9; border-top-color: var(--v2-teal); border-radius: 50%; animation: spin 800ms linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 1024px) {
    .login-layout { width: min(900px, calc(100% - 32px)); }
    .login-card { grid-template-columns: 0.82fr 1.18fr; }
    .login-intro, .login-form-panel { padding: 36px; }
    .benefits { gap: 14px; }
    .dashboard { width: min(920px, calc(100% - 40px)); }
    .app-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .app-card { min-height: 140px; }
}

@media (max-width: 740px) {
    body::before { display: none; }
    .login-layout { width: min(560px, calc(100% - 24px)); padding-top: 20px; }
    .brand-login { margin-bottom: 16px; }
    .brand-login img { width: min(320px, 82vw); }
    .login-card { display: block; overflow: visible; }
    .login-intro { padding: 25px 24px; border-right: 0; border-bottom: 1px solid #eee6cd; border-radius: var(--v2-radius-lg) var(--v2-radius-lg) 0 0; }
    .login-intro::after, .benefits { display: none; }
    .login-intro h1 { font-size: 1.65rem; }
    .intro-copy { margin: 10px 0 0; font-size: 0.92rem; line-height: 1.45; }
    .login-form-panel { padding: 26px 24px 28px; }
    .login-form-panel h2 { margin-bottom: 20px; font-size: 1.55rem; }
    .topbar { min-height: 72px; padding: 10px 14px; }
    .brand-dashboard img { height: 52px; margin: -5px 0; }
    .topbar-actions > .preview-badge, .user-texte { display: none; }
    .user-menu summary { padding-right: 8px; }
    .dashboard { width: min(560px, calc(100% - 24px)); padding-top: 34px; }
    .dashboard-heading h1 { font-size: 2.25rem; }
    .app-list { grid-template-columns: 1fr; }
    .app-card { grid-template-columns: 92px 1fr auto; min-height: 108px; padding: 16px; }
    .app-logo { grid-column: auto; width: 92px; height: 62px; justify-content: center; }
    .app-logo img { max-width: 88px; max-height: 58px; }
    .dashboard-footer { flex-direction: column; gap: 8px; }
}

@media (max-width: 430px) {
    .role-options { grid-template-columns: 1fr; }
    .role-option > span { justify-content: flex-start; }
    .login-form-panel { padding: 24px 18px 26px; }
    .login-intro { padding-inline: 18px; }
    .featured-topline { display: block; }
    .ghost-button { margin-top: 14px; }
    .featured-content { grid-template-columns: 1fr; }
    .featured-visual { display: none; }
    .app-card { grid-template-columns: 76px 1fr auto; gap: 12px; }
    .app-logo { width: 76px; }
    .app-logo img { max-width: 72px; }
}

@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
    *, *::before, *::after { scroll-behavior: auto !important; transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; }
}

@media print {
    .topbar, .dashboard-footer, .preview-badge { display: none; }
    body { background: #fff; }
    .dashboard { width: 100%; padding: 0; }
}
