:root {
    --green: #107c41;
    --green-dark: #0b5a2f;
    --green-soft: #e6f4ec;
    --ink: #1c2a24;
    --muted: #5d6b64;
    --line: #dfe6e2;
    --bg: #f6f8f7;
    --card: #ffffff;
    --radius: 14px;
    --shadow: 0 1px 2px rgba(16, 40, 28, .06), 0 8px 24px rgba(16, 40, 28, .06);
}

html, body {
    font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
    background: var(--bg);
    color: var(--ink);
}

body { display: flex; flex-direction: column; min-height: 100vh; }
#app { display: flex; flex-direction: column; flex: 1; }
main { flex: 1; }
h1:focus { outline: none; }
a { color: var(--green); }
code { color: inherit; }

/* Top bar */
.topbar {
    background: var(--card);
    border-bottom: 1px solid var(--line);
    padding: .75rem 0;
    position: sticky;
    top: 0;
    z-index: 10;
}

.brand {
    display: flex;
    align-items: center;
    gap: .6rem;
    color: var(--ink);
    text-decoration: none;
    font-size: 1.15rem;
}

    .brand b { color: var(--green); }

.brand-logo {
    display: grid;
    place-items: center;
    width: 2.2rem;
    height: 2.2rem;
    border-radius: 9px;
    background: var(--green);
    color: #fff;
    font-weight: 700;
    font-style: italic;
}

.toplink {
    color: var(--muted);
    text-decoration: none;
    font-weight: 500;
    padding: .45rem .9rem;
    border-radius: 999px;
}

    .toplink:hover { color: var(--ink); background: var(--bg); }
    .toplink.active { color: var(--green-dark); background: var(--green-soft); }

.footer {
    border-top: 1px solid var(--line);
    background: var(--card);
    color: var(--muted);
    font-size: .9rem;
    padding: 1.5rem 0;
}

/* Buttons */
.btn-academy {
    background: var(--green);
    border-color: var(--green);
    color: #fff;
    font-weight: 600;
}

    .btn-academy:hover, .btn-academy:focus { background: var(--green-dark); border-color: var(--green-dark); color: #fff; }

.btn-outline-academy {
    border: 1px solid var(--green);
    color: var(--green);
    font-weight: 600;
}

    .btn-outline-academy:hover { background: var(--green-soft); color: var(--green-dark); }

.btn:focus-visible, input:focus-visible, .form-check-input:focus {
    box-shadow: 0 0 0 .2rem rgba(16, 124, 65, .3);
    outline: none;
}

/* Hero */
.hero {
    background: radial-gradient(circle at 85% 20%, #d7efe1 0, transparent 45%), linear-gradient(180deg, #fff 0%, var(--bg) 100%);
    padding: 4.5rem 0;
    border-bottom: 1px solid var(--line);
}

.eyebrow {
    display: inline-block;
    background: var(--green-soft);
    color: var(--green-dark);
    font-weight: 600;
    font-size: .85rem;
    padding: .3rem .8rem;
    border-radius: 999px;
    margin-bottom: 1rem;
}

.hero-title {
    font-size: clamp(2rem, 4vw, 3.1rem);
    font-weight: 800;
    line-height: 1.1;
    letter-spacing: -.02em;
}

    .hero-title span { color: var(--green); }

.hero-lead { font-size: 1.15rem; color: var(--muted); margin: 1.2rem 0 1.8rem; max-width: 34rem; }

/* Decorative spreadsheet */
.sheet {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
    transform: rotate(1deg);
}

.sheet-bar { display: flex; align-items: center; gap: .6rem; padding: .6rem .8rem; border-bottom: 1px solid var(--line); font-size: .95rem; }

.sheet table { width: 100%; border-collapse: collapse; font-size: .95rem; }

.sheet th, .sheet td { border: 1px solid var(--line); padding: .45rem .7rem; }
.sheet th { background: #f1f4f2; color: var(--muted); font-weight: 500; text-align: center; width: 2.5rem; }
.sheet td.sel { outline: 2px solid var(--green); outline-offset: -2px; background: var(--green-soft); font-weight: 600; }

/* Formula bar (shared by lessons and the workshop) */
.fx {
    color: var(--green);
    font-style: italic;
    font-weight: 700;
    font-family: Georgia, serif;
    padding-right: .6rem;
    border-right: 1px solid var(--line);
}

.formula {
    display: flex;
    align-items: center;
    gap: .6rem;
    background: var(--bg);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: .5rem .75rem;
    overflow-x: auto;
}

    .formula code { white-space: nowrap; font-size: .95rem; }

/* Progress + modules */
.progress-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.25rem 1.5rem; box-shadow: var(--shadow); }
.progress { height: .6rem; background: var(--green-soft); }
.progress-bar { background: var(--green); transition: width .3s; }

.module-head { display: flex; align-items: center; gap: .8rem; margin-bottom: 1.2rem; flex-wrap: wrap; }
    .module-head h2 { font-size: 1.4rem; font-weight: 700; margin: 0; }

.badge-level { font-size: .75rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; padding: .3rem .7rem; border-radius: 999px; }
.lvl-1 { background: #e6f4ec; color: #0b5a2f; }
.lvl-2 { background: #fff3d6; color: #7a5300; }
.lvl-3 { background: #fde4e4; color: #8f1d1d; }

.lesson {
    position: relative;
    height: 100%;
    display: flex;
    flex-direction: column;
    gap: .8rem;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 1.4rem;
    box-shadow: var(--shadow);
    transition: transform .15s, box-shadow .15s;
}

    .lesson:hover { transform: translateY(-2px); box-shadow: 0 2px 4px rgba(16, 40, 28, .06), 0 14px 32px rgba(16, 40, 28, .1); }
    .lesson h3 { font-size: 1.1rem; font-weight: 700; margin: 0; padding-right: 2.5rem; }
    .lesson p { color: var(--muted); margin: 0; flex: 1; }
    .lesson.done { border-color: #9fd3b4; }

.lesson-num {
    position: absolute;
    top: 1.2rem;
    right: 1.2rem;
    width: 2rem;
    height: 2rem;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: var(--bg);
    border: 1px solid var(--line);
    font-weight: 700;
    font-size: .9rem;
    color: var(--muted);
}

.done .lesson-num { background: var(--green); border-color: var(--green); color: #fff; }

.lesson-actions { display: flex; align-items: center; justify-content: space-between; gap: .5rem; flex-wrap: wrap; }

.form-check-input:checked { background-color: var(--green); border-color: var(--green); }

/* Workshop */
.page-head { background: var(--card); border-bottom: 1px solid var(--line); padding: 2rem 0 1.5rem; }
    .page-head h1 { font-size: 1.9rem; font-weight: 800; margin: .3rem 0; }
    .page-head p { color: var(--muted); margin: 0; }

.crumb { text-decoration: none; font-size: .9rem; font-weight: 500; }

.formula-input { background: var(--card); padding: .7rem 1rem; cursor: text; }
    .formula-input:focus-within { border-color: var(--green); box-shadow: 0 0 0 .2rem rgba(16, 124, 65, .2); }
    .formula-input.invalid { border-color: #c62828; }
    .formula-input input { flex: 1; min-width: 0; border: 0; outline: 0; box-shadow: none; background: transparent; font-family: ui-monospace, Consolas, monospace; font-size: 1.15rem; }

.formula-error { color: #c62828; min-height: 1.6em; padding: .25rem .2rem; font-size: .9rem; }

.workspace { height: 560px; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); background: var(--card); }

.tip { color: var(--muted); font-size: .9rem; margin-top: .8rem; }

/* Account */
.user-chip { background: var(--green-soft); color: var(--green-dark); font-size: .9rem; }

.auth-card { max-width: 26rem; margin: 0 auto; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 2rem; box-shadow: var(--shadow); }
    .auth-card h1 { font-size: 1.6rem; font-weight: 800; }

.auth-tabs { display: flex; background: var(--bg); border-radius: 999px; padding: .25rem; margin-bottom: 1.5rem; }
    .auth-tabs button { flex: 1; border: 0; background: transparent; border-radius: 999px; padding: .5rem; font-weight: 600; color: var(--muted); }
    .auth-tabs button.active { background: var(--card); color: var(--green-dark); box-shadow: 0 1px 3px rgba(0, 0, 0, .1); }

.form-control:focus { border-color: var(--green); box-shadow: 0 0 0 .2rem rgba(16, 124, 65, .2); }

/* Blazor template plumbing */
#blazor-error-ui {
    color-scheme: light only;
    background: lightyellow;
    bottom: 0;
    box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
    box-sizing: border-box;
    display: none;
    left: 0;
    padding: 0.6rem 1.25rem 0.7rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
}

    #blazor-error-ui .dismiss {
        cursor: pointer;
        position: absolute;
        right: 0.75rem;
        top: 0.5rem;
    }

.loading-progress {
    position: absolute;
    display: block;
    width: 8rem;
    height: 8rem;
    inset: 20vh 0 auto 0;
    margin: 0 auto 0 auto;
}

    .loading-progress circle {
        fill: none;
        stroke: #e0e0e0;
        stroke-width: 0.6rem;
        transform-origin: 50% 50%;
        transform: rotate(-90deg);
    }

        .loading-progress circle:last-child {
            stroke: var(--green);
            stroke-dasharray: calc(3.141 * var(--blazor-load-percentage, 0%) * 0.8), 500%;
            transition: stroke-dasharray 0.05s ease-in-out;
        }

.loading-progress-text {
    position: absolute;
    text-align: center;
    font-weight: bold;
    inset: calc(20vh + 3.25rem) 0 auto 0.2rem;
}

    .loading-progress-text:after {
        content: var(--blazor-load-percentage-text, "Chargement");
    }
