/* ===== Design tokens ===== */
:root {
    --sidebar-w: 260px;
    --radius-lg: 14px;
    --radius-md: 10px;
    --radius-sm: 7px;
    --shadow-sm: 0 1px 2px rgba(15, 23, 42, .06);
    --shadow-md: 0 8px 24px rgba(15, 23, 42, .08);

    --bg: #f4f5f8;
    --surface: #ffffff;
    --surface-hover: #f8f9fc;
    --border: #e5e7ec;
    --text: #16181d;
    --text-muted: #676c76;
    --text-subtle: #6b717c;

    --primary: #4f46e5;
    --primary-hover: #4338ca;
    --primary-soft: #eef0ff;
    --primary-text: #ffffff;
    --on-primary: #ffffff;
    --primary-strong: #4f46e5;
    --accent-2: #7c3aed;

    --success: #16a34a;
    --success-soft: #e9f9ef;
    --danger: #dc2626;
    --danger-soft: #fdecec;
    --warning: #d97706;
    --warning-soft: #fef3e2;

    color-scheme: light;
    padding-top: env(safe-area-inset-top, 0px);
    padding-bottom: env(safe-area-inset-bottom, 0px);
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        color-scheme: dark;
        --bg: #0b0d14;
        --surface: #12151f;
        --surface-2: #181c27;
        --surface-hover: #1b1f2b;
        --border: rgba(255, 255, 255, .08);
        --text: #f8fafc;
        --text-muted: #a1a1aa;
        --text-subtle: #8b93a1;

        --primary: #6366f1;
        --primary-hover: #818cf8;
        --primary-soft: rgba(99, 102, 241, .18);

        --success: #22c55e;
        --success-soft: rgba(34, 197, 94, .14);
        --danger: #f87171;
        --danger-soft: rgba(248, 113, 113, .14);
        --warning: #fbbf24;
        --warning-soft: rgba(251, 191, 36, .14);

        --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3);
        --shadow-md: 0 8px 24px rgba(0, 0, 0, .4);
    }
}

:root[data-theme="dark"] {
    color-scheme: dark;
    --bg: #0b0d14;
    --surface: #12151f;
    --surface-2: #181c27;
    --surface-hover: #1b1f2b;
    --border: rgba(255, 255, 255, .08);
    --text: #f8fafc;
    --text-muted: #a1a1aa;
    --text-subtle: #8b93a1;

    --primary: #6366f1;
    --primary-hover: #818cf8;
    --primary-soft: rgba(99, 102, 241, .18);

    --success: #22c55e;
    --success-soft: rgba(34, 197, 94, .14);
    --danger: #f87171;
    --danger-soft: rgba(248, 113, 113, .14);
    --warning: #fbbf24;
    --warning-soft: rgba(251, 191, 36, .14);

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3);
    --shadow-md: 0 8px 24px rgba(0, 0, 0, .4);
}

/* ===== Reset ===== */
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
    margin: 0;
    font-family: -apple-system, "Segoe UI", system-ui, Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
}
img { max-width: 100%; }
[hidden] { display: none !important; }
a { color: inherit; }
h1, h2, h3, p { margin: 0 0 .5rem; }
h1 { font-size: 1.5rem; font-weight: 700; letter-spacing: -.01em; }
h2 { font-size: 1.1rem; font-weight: 600; margin-top: 1.75rem; letter-spacing: -.005em; }
.icon { display: inline-block; vertical-align: -4px; flex-shrink: 0; }

/* ===== Animations ===== */
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}
@keyframes growWidth {
    from { width: 0; }
}
@keyframes popIn {
    0% { transform: scale(.8); opacity: 0; }
    70% { transform: scale(1.08); opacity: 1; }
    100% { transform: scale(1); }
}
@keyframes themeFlip {
    0% { transform: rotate(0deg) scale(1); }
    50% { transform: rotate(180deg) scale(.7); }
    100% { transform: rotate(360deg) scale(1); }
}
@keyframes bellRing {
    0%, 100% { transform: rotate(0); }
    20% { transform: rotate(-12deg); }
    40% { transform: rotate(10deg); }
    60% { transform: rotate(-6deg); }
    80% { transform: rotate(4deg); }
}

.page { animation: fadeInUp .35s ease both; }

#theme-toggle.is-flipping { animation: themeFlip .4s ease; }
#reminder-toggle.is-active .icon { animation: bellRing .5s ease; }

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

/* ===== App shell ===== */
.app-shell {
    display: flex;
    min-height: 100vh;
}

.nav-toggle-checkbox { position: absolute; opacity: 0; pointer-events: none; }

.sidebar-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .45);
    z-index: 40;
    opacity: 0;
    visibility: hidden;
    transition: opacity .2s ease, visibility .2s ease;
}

.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: var(--sidebar-w);
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    transform: translateX(-100%);
    transition: transform .25s cubic-bezier(.22, .8, .3, 1), background .2s ease, border-color .2s ease;
    z-index: 50;
    padding: 1rem .75rem;
}
:root[data-theme="dark"] .sidebar { background: var(--surface-2); }
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .sidebar { background: var(--surface-2); }
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: .35rem .5rem 1.1rem;
    margin-bottom: .35rem;
    border-bottom: 1px solid var(--border);
}

.brand {
    display: flex;
    align-items: center;
    gap: .5rem;
    font-weight: 700;
    letter-spacing: .01em;
    text-decoration: none;
    color: var(--text);
}
.brand .icon { color: var(--primary); }

.sidebar-close {
    color: var(--text-muted);
    cursor: pointer;
    padding: .25rem;
    line-height: 0;
}

.sidebar-nav {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: .15rem;
    overflow-y: auto;
}

.nav-group-label {
    margin: 1rem .6rem .35rem;
    font-size: .7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--text-subtle);
}

.nav-link {
    display: flex;
    align-items: center;
    gap: .65rem;
    padding: .55rem .6rem;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    text-decoration: none;
    font-size: .92rem;
    font-weight: 500;
    background: none;
    border: none;
    width: 100%;
    text-align: left;
    cursor: pointer;
    font-family: inherit;
    transition: background .15s ease, color .15s ease;
}
.nav-link:hover { background: var(--surface-hover); color: var(--text); }
.nav-link.active {
    background: var(--primary);
    color: var(--on-primary);
    box-shadow: 0 4px 14px -2px color-mix(in srgb, var(--primary) 55%, transparent);
}
.nav-link .icon { color: currentColor; opacity: .85; }
.nav-link, .bn-link, .accent-swatch, .setting-row { transition: background .15s ease, color .15s ease, box-shadow .15s ease, transform .1s ease; }
.nav-link:active { transform: scale(.98); }

.sidebar-footer {
    border-top: 1px solid var(--border);
    padding-top: .5rem;
    margin-top: .5rem;
    display: flex;
    flex-direction: column;
    gap: .15rem;
}
.sidebar-footer form { margin: 0; }
.nav-link-btn { justify-content: flex-start; }

.main-wrap {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.topbar {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: .6rem .75rem;
    padding: .85rem 1.25rem;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 20;
}
:root[data-theme="dark"] .topbar {
    background: color-mix(in srgb, var(--surface) 88%, transparent);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
}
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .topbar {
        background: color-mix(in srgb, var(--surface) 88%, transparent);
        -webkit-backdrop-filter: blur(10px);
        backdrop-filter: blur(10px);
    }
}

.topbar-brand {
    grid-column: 1;
    min-width: 0;
}
.topbar-brand span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
@media (min-width: 768px) {
    /* Le logo est déjà dans la barre latérale, toujours visible à cette largeur : pas besoin de le répéter ici. */
    .topbar-brand { display: none; }
}

/* Colonnes fixes (et non déduites de l'ordre des éléments) : le logo peut disparaître
   en display:none sans que la recherche et la cloche ne se décalent vers la gauche. */
.topbar-search { grid-column: 2; }
.topbar-bell { grid-column: 3; justify-self: end; }

.icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.1rem;
    height: 2.1rem;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    cursor: pointer;
    background: none;
    border: none;
}
.icon-btn:hover { background: var(--surface-hover); color: var(--text); }
.icon-btn.is-active { color: var(--primary); }

.theme-icon-dark { display: none; }
:root[data-theme="dark"] .theme-icon-light { display: none; }
:root[data-theme="dark"] .theme-icon-dark { display: inline-block; }
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .theme-icon-light { display: none; }
    :root:not([data-theme="light"]) .theme-icon-dark { display: inline-block; }
}

.page {
    flex: 1;
    width: 100%;
    max-width: 1080px;
    margin: 0 auto;
    padding: 1.5rem 1.25rem 3rem;
}

@media (min-width: 768px) {
    .sidebar { position: sticky; height: 100vh; transform: none; }
    .sidebar-close, .sidebar-backdrop { display: none !important; }
}

.nav-toggle-checkbox:checked ~ .sidebar-backdrop { opacity: 1; visibility: visible; }
.nav-toggle-checkbox:checked ~ .sidebar { transform: translateX(0); }

/* ===== Guest (login) layout ===== */
.app-shell-guest {
    align-items: center;
    justify-content: center;
}
.app-shell-guest .main-wrap { flex: none; width: 100%; }
.app-shell-guest .page {
    max-width: 360px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    margin: 0 auto;
}
.auth-card {
    width: min(100%, 360px);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    padding: 2rem 1.75rem;
    animation: auth-in .5s cubic-bezier(.2, .8, .2, 1) both;
}
.auth-card.has-error { animation: auth-in .5s cubic-bezier(.2, .8, .2, 1) both, auth-shake .4s ease .5s; }
@keyframes auth-in { from { opacity: 0; transform: translateY(14px) scale(.97); } to { opacity: 1; transform: none; } }
@keyframes auth-shake {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-8px); }
    40% { transform: translateX(7px); }
    60% { transform: translateX(-5px); }
    80% { transform: translateX(3px); }
}
.auth-brand { color: var(--text); margin-bottom: 1.5rem; }
.auth-brand .brand-logo {
    animation: auth-logo-pop .55s cubic-bezier(.34, 1.56, .64, 1) .15s both;
}
@keyframes auth-logo-pop { from { transform: scale(.5) rotate(-10deg); opacity: 0; } to { transform: none; opacity: 1; } }
.auth-title { margin: 0 0 .4rem; font-size: 1.25rem; }
.auth-sub { margin: 0 0 1.25rem; font-size: .88rem; line-height: 1.5; color: var(--text-muted); }
.auth-error {
    display: flex;
    align-items: center;
    gap: .5rem;
    margin: 0 0 1.1rem;
    padding: .6rem .8rem;
    font-size: .85rem;
    color: var(--danger);
    background: var(--danger-soft);
    border-radius: var(--radius-sm);
    animation: auth-in .35s ease both;
}
.auth-error .icon { flex: none; }
.auth-submit { width: 100%; justify-content: center; }
.auth-links { margin: -.4rem 0 1rem; text-align: right; font-size: .85rem; }
.auth-links a { color: var(--text-muted); text-decoration: none; }
.auth-links a:hover { color: var(--primary); text-decoration: underline; }
.auth-card-center { text-align: center; }
.auth-icon {
    display: grid;
    place-items: center;
    width: 56px;
    height: 56px;
    margin: 0 auto 1rem;
    border-radius: 50%;
    animation: auth-logo-pop .5s cubic-bezier(.34, 1.56, .64, 1) both;
}
.auth-icon .icon { width: 26px; height: 26px; }
.auth-icon-success { color: var(--success); background: var(--success-soft); }

.password-field { position: relative; display: block; }
.password-field input { width: 100%; padding-right: 2.6rem; }
.password-toggle {
    position: absolute;
    top: 50%;
    right: .35rem;
    transform: translateY(-50%);
    display: grid;
    place-items: center;
    width: 2rem;
    height: 2rem;
    color: var(--text-subtle);
    background: none;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
}
.password-toggle:hover { color: var(--text); background: var(--surface-hover); }
.pw-icon-hide { display: none; }
.password-toggle.is-visible { color: var(--primary); }
.password-toggle.is-visible .pw-icon-show { display: none; }
.password-toggle.is-visible .pw-icon-hide { display: inline-block; }
.password-toggle .icon { transition: transform .15s cubic-bezier(.34, 1.56, .64, 1); }
.password-toggle:active .icon { transform: scale(.82); }
.helptext ul { margin: .3rem 0 0; padding-left: 1.1rem; }
.helptext li { margin-bottom: .15rem; }
@media (prefers-reduced-motion: reduce) {
    .auth-card, .auth-card.has-error, .auth-brand .brand-logo, .auth-error, .auth-icon { animation: none; }
}

/* ===== Page header ===== */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 1.25rem;
}
.page-header-text .muted { margin-top: -.25rem; }

.muted { color: var(--text-muted); font-size: .9rem; }
.subtle { color: var(--text-subtle); font-size: .82rem; }

/* ===== Buttons ===== */
.btn {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    background: var(--primary);
    color: var(--on-primary);
    border: none;
    border-radius: var(--radius-sm);
    padding: .55rem 1rem;
    text-decoration: none;
    font: inherit;
    font-weight: 600;
    font-size: .88rem;
    cursor: pointer;
    transition: background .15s ease, transform .1s ease;
}
.btn:hover { background: var(--primary-hover); }
.btn:active { transform: scale(.96); }
.btn-danger { background: var(--danger); }
.btn-danger:hover { filter: brightness(1.08); }
.btn-ghost {
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
}
.btn-ghost:hover { background: var(--surface-hover); }
.btn-sm { padding: .35rem .7rem; font-size: .8rem; }

.icon-action {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.9rem;
    height: 1.9rem;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    background: none;
    border: none;
    cursor: pointer;
    text-decoration: none;
    transition: background .15s ease, color .15s ease, transform .1s ease;
}
.icon-action:hover { background: var(--surface-hover); color: var(--text); }
.icon-action:active { transform: scale(.9); }
.icon-action.danger:hover { color: var(--danger); background: var(--danger-soft); }
.icon-action.favorite.is-active { color: var(--warning); }
.icon-action.favorite.is-active .icon { fill: currentColor; animation: popIn .3s ease; }

/* ===== Stats ===== */
.stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(140px, 100%), 1fr));
    gap: .9rem;
    margin-bottom: 1.75rem;
}
.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 1rem 1.1rem;
    display: flex;
    flex-direction: column;
    gap: .2rem;
    box-shadow: var(--shadow-sm);
    transition: transform .15s ease, box-shadow .15s ease;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.stat-value { font-size: 1.6rem; font-weight: 700; line-height: 1; }
.stat-label { color: var(--text-muted); font-size: .82rem; }

/* ===== Dashboard sections ===== */
.dash-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(240px, 100%), 1fr));
    gap: 1.25rem;
    margin-top: 1.5rem;
}
.panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 1.1rem 1.25rem;
    box-shadow: var(--shadow-sm);
    transition: box-shadow .15s ease;
}
.panel:hover { box-shadow: var(--shadow-md); }
.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: .4rem 1rem;
    margin-bottom: .75rem;
}
.panel-header h2 { margin: 0; }
.panel-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .6rem; }
.panel-list li {
    display: flex;
    align-items: center;
    gap: .5rem;
    justify-content: space-between;
    font-size: .9rem;
}
.panel-list a {
    min-width: 0;
    text-decoration: none;
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.panel-list a:hover { color: var(--primary); }
.panel-list .badge { flex-shrink: 0; }
.panel-empty { color: var(--text-subtle); font-size: .88rem; }

/* ===== Cards / list ===== */
.card-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: .55rem;
}

.card {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .5rem .85rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: .85rem 1.1rem;
    box-shadow: var(--shadow-sm);
    transition: border-color .15s ease, transform .15s ease, box-shadow .15s ease;
}
.card:hover { border-color: var(--primary); transform: translateY(-1px); box-shadow: var(--shadow-md); }
.card a.card-title { color: var(--text); text-decoration: none; font-weight: 600; }
.card > .icon:first-child { color: var(--primary); }
.card a.card-title:hover { color: var(--primary); }
.card-actions { display: flex; align-items: center; gap: .15rem; margin-left: auto; }

.badge {
    display: inline-flex;
    align-items: center;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: .15rem .65rem;
    font-size: .78rem;
    color: var(--text-muted);
    white-space: nowrap;
}
.badge-primary { background: var(--primary-soft); color: var(--primary); border-color: transparent; }
a.badge { text-decoration: none; cursor: pointer; }
a.badge:hover { border-color: var(--primary); color: var(--primary); }
.badge-success { background: var(--success-soft); color: var(--success); border-color: transparent; }
.badge-warning { background: var(--warning-soft); color: var(--warning); border-color: transparent; }
.badge-danger { background: var(--danger-soft); color: var(--danger); border-color: transparent; }

.status-mastered, .status-done { background: var(--success-soft); color: var(--success); border-color: transparent; }
.status-in_progress { background: var(--warning-soft); color: var(--warning); border-color: transparent; }
.status-todo { background: var(--bg); color: var(--text-muted); }

.progress-bar {
    position: relative;
    width: 72px;
    height: 6px;
    border-radius: 999px;
    background: var(--border);
    overflow: hidden;
    flex-shrink: 0;
}
.progress-bar span {
    position: absolute;
    inset: 0;
    width: var(--pct, 0%);
    background: var(--primary);
    border-radius: 999px;
    animation: growWidth .7s ease-out both;
}

/* ===== Empty state ===== */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: .4rem;
    padding: 2.75rem 1.5rem;
    text-align: center;
    color: var(--text-muted);
    background: linear-gradient(180deg, var(--primary-soft), transparent 70%);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
}
.empty-state .icon {
    width: 64px;
    height: 64px;
    margin-bottom: .5rem;
    padding: 16px;
    color: var(--primary);
    background: var(--primary-soft);
    border-radius: 50%;
    animation: floaty 3.2s ease-in-out infinite;
}
.empty-state p { margin: 0; max-width: 34ch; font-weight: 600; line-height: 1.45; color: var(--text); }
.empty-state a {
    display: inline-flex;
    margin-top: .7rem;
    padding: .5rem 1.15rem;
    color: var(--on-primary);
    font-weight: 600;
    text-decoration: none;
    background: var(--primary);
    border-radius: 999px;
    transition: transform .15s ease, background .15s ease;
}
.empty-state a:hover { background: var(--primary-hover); transform: translateY(-1px); }
@keyframes floaty { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }

/* ===== Filters / search ===== */
.filter-bar {
    display: flex;
    flex-wrap: wrap;
    gap: .6rem;
    margin-bottom: 1.1rem;
}
.search-box {
    position: relative;
    flex: 1;
    min-width: 180px;
}
.search-box .icon {
    position: absolute;
    left: .65rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-subtle);
}
.search-box input {
    width: 100%;
    padding: .55rem .8rem .55rem 2.2rem;
}

.topbar-search {
    min-width: 0;
    width: 100%;
    max-width: 420px;
    margin: 0 auto;
}
.topbar-search input {
    min-width: 0;
    padding-top: .45rem;
    padding-bottom: .45rem;
}

.filter-tabs { display: flex; flex-wrap: wrap; gap: .35rem; }
.filter-tab {
    padding: .4rem .8rem;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text-muted);
    text-decoration: none;
    font-size: .85rem;
    font-weight: 500;
    transition: background .15s ease, color .15s ease, border-color .15s ease;
}
.filter-tab:hover { border-color: var(--primary); color: var(--text); }
.filter-tab.active { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }

/* ===== Forms ===== */
form.styled-form { max-width: 620px; }
form p { display: flex; flex-direction: column; gap: .3rem; margin: 0 0 1rem; }
form label {
    font-size: .82rem;
    font-weight: 600;
    color: var(--text-muted);
}
form input:not([type="checkbox"]):not([type="radio"]),
form select,
form textarea {
    padding: .6rem .75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font: inherit;
    background: var(--surface);
    color: var(--text);
    width: 100%;
}
form select[multiple] { min-height: 7rem; }
form textarea { min-height: 5.5rem; resize: vertical; }
form input:focus, form select:focus, form textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-soft);
}
form p:has(input[type="checkbox"]):not(:has(.tag-checks)) {
    flex-direction: row;
    align-items: center;
    gap: .55rem;
}
form input[type="checkbox"], form input[type="radio"] { width: 1.05rem; height: 1.05rem; accent-color: var(--primary); }
form .helptext { font-size: .78rem; color: var(--text-subtle); font-weight: 400; }
form ul.errorlist { list-style: none; margin: .25rem 0 0; padding: 0; color: var(--danger); font-size: .82rem; }
.form-actions { display: flex; gap: .6rem; margin-top: .5rem; }

/* ===== Detail page ===== */
.detail-meta { color: var(--text-muted); font-size: .88rem; margin-bottom: 1rem; }
.detail-body { line-height: 1.6; }
pre {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: .8rem 1rem;
    overflow-x: auto;
    font-size: .85rem;
}
code { font-family: ui-monospace, "SF Mono", Consolas, monospace; }

/* ===== Calendrier ===== */
.calendar-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: .75rem;
}

.calendar-legend {
    display: flex;
    flex-wrap: wrap;
    gap: .9rem;
    margin-bottom: 1rem;
}
.legend-item {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    font-size: .8rem;
    color: var(--text-muted);
}
.legend-dot {
    width: .6rem;
    height: .6rem;
    border-radius: 999px;
    flex-shrink: 0;
}
.legend-task { background: var(--primary); }
.legend-goal { background: var(--warning); }
.legend-revision { background: var(--success); }
.legend-study { background: var(--text-subtle); }

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 1px;
    background: var(--border);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    overflow: hidden;
}

.calendar-weekday {
    background: var(--surface);
    padding: .5rem .3rem;
    text-align: center;
    font-size: .72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--text-subtle);
}

.calendar-day {
    background: var(--surface);
    min-height: 84px;
    min-width: 0;
    padding: .35rem;
    display: flex;
    flex-direction: column;
    gap: .2rem;
    overflow: hidden;
}
.calendar-day.is-outside { background: var(--bg); }
.calendar-day.is-outside .day-number { color: var(--text-subtle); }

.day-number {
    font-size: .78rem;
    font-weight: 600;
    color: var(--text-muted);
    width: 1.4rem;
    height: 1.4rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.calendar-day.is-today .day-number {
    background: var(--primary);
    color: var(--on-primary);
    border-radius: 999px;
}

.calendar-event {
    display: block;
    width: 100%;
    min-width: 0;
    font-size: .68rem;
    line-height: 1.3;
    padding: .1rem .35rem;
    border-radius: 4px;
    text-decoration: none;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    box-sizing: border-box;
}
.calendar-event-task { background: var(--primary-soft); color: var(--primary); }
.calendar-event-goal { background: var(--warning-soft); color: var(--warning); }
.calendar-event-revision { background: var(--success-soft); color: var(--success); }
.calendar-event-study { background: var(--bg); color: var(--text-muted); border: 1px solid var(--border); }

.calendar-day-events { display: flex; flex-direction: column; gap: .2rem; min-width: 0; }
.calendar-event-more {
    align-self: center;
    padding: 0 .3rem;
    font-size: .62rem;
    font-weight: 700;
    color: var(--text-subtle);
    text-decoration: none;
}
.calendar-event-more:hover { color: var(--primary); }

@media (max-width: 600px) {
    .calendar-day { min-height: 58px; padding: .2rem; }
    .calendar-weekday { font-size: .62rem; padding: .35rem .1rem; }
    /* La cellule est trop étroite pour du texte lisible : chaque événement devient une
       pastille de couleur. Le libellé reste dans le lien (accessible, lu par un lecteur
       d'écran) mais n'est plus affiché ; le jour complet reste consultable en un tap sur
       le numéro du jour, qui ouvre la vue « Jour » avec le détail en clair. */
    .calendar-day-events { flex-direction: row; flex-wrap: wrap; gap: 3px; margin-top: 1px; }
    .calendar-event {
        display: block;
        width: 7px;
        height: 7px;
        padding: 0;
        border-radius: 50%;
        border: none;
    }
    .calendar-event span {
        position: absolute;
        width: 1px;
        height: 1px;
        overflow: hidden;
        clip-path: inset(50%);
        white-space: nowrap;
    }
    /* Les teintes « soft » (pensées pour un fond de pilule avec du texte dessus) sont trop
       pâles pour une pastille de 7 px isolée : couleur pleine ici pour rester visible. */
    .calendar-event-task { background: var(--primary); }
    .calendar-event-goal { background: var(--warning); }
    .calendar-event-revision { background: var(--success); }
    .calendar-event-study { background: var(--text-muted); border: none; }
    .calendar-event-more { font-size: .58rem; }
}

.pdf-viewer {
    width: 100%;
    height: 80vh;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--surface);
    margin-top: .5rem;
}
@media (max-width: 480px) {
    .pdf-viewer { height: 65vh; }
}

.code-block { position: relative; }
.code-block pre { margin: 0; padding-right: 2.75rem; }
.code-block .copy-btn { position: absolute; top: .4rem; right: .4rem; }
.copy-btn.is-active { color: var(--success); background: var(--success-soft); animation: popIn .3s ease; }
.tag-row { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .75rem; }
.back-link {
    display: inline-flex;
    align-items: center;
    gap: .3rem;
    margin-top: 1.75rem;
    text-decoration: none;
    color: var(--text-muted);
    font-size: .88rem;
}
.back-link:hover { color: var(--primary); }

/* ===== Pagination ===== */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: .4rem;
    margin-top: 1.75rem;
}
.pagination a, .pagination span {
    display: inline-flex;
    align-items: center;
    gap: .3rem;
    padding: .4rem .75rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    text-decoration: none;
    font-size: .85rem;
    color: var(--text-muted);
}
.pagination a:hover { border-color: var(--primary); color: var(--text); }
.pagination .current { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }

/* ===== Messages / toasts ===== */
.messages { list-style: none; margin: 0 0 1.25rem; padding: 0; display: flex; flex-direction: column; gap: .5rem; }
.message {
    padding: .65rem .9rem;
    border-radius: var(--radius-sm);
    background: var(--primary-soft);
    color: var(--primary);
    font-size: .88rem;
    transition: opacity .3s ease, transform .3s ease;
}
.message.success { background: var(--success-soft); color: var(--success); }
.message.error { background: var(--danger-soft); color: var(--danger); }
.message-hide { opacity: 0; transform: translateY(-6px); }

/* ===== Responsive ===== */
@media (max-width: 480px) {
    .page { padding: 1.1rem .9rem 2.5rem; }
    .card { padding: .75rem .9rem; }
    .card-actions { margin-left: 0; width: 100%; justify-content: flex-end; }
}

/* ===== Réseau instable : progression, chargement, hors ligne ===== */
.net-bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    z-index: 1100;
    pointer-events: none;
    opacity: 0;
    transition: opacity .2s ease;
}
.net-bar.is-active { opacity: 1; }
.net-bar > span {
    display: block;
    height: 100%;
    width: 0;
    background: linear-gradient(90deg, var(--primary), var(--primary-hover));
    box-shadow: 0 0 10px var(--primary);
    border-radius: 0 3px 3px 0;
    transition: width .4s ease;
}

.net-overlay {
    position: fixed;
    inset: 0;
    z-index: 1090;
    display: grid;
    place-items: center;
    padding: 1rem;
    background: rgba(15, 23, 42, .25);
    background: color-mix(in srgb, var(--bg) 55%, transparent);
    -webkit-backdrop-filter: blur(2px);
    backdrop-filter: blur(2px);
    opacity: 0;
    pointer-events: none;
    transition: opacity .2s ease;
}
.net-overlay.is-visible { opacity: 1; pointer-events: auto; }
.net-overlay.is-visible .net-card { transform: none; }
.net-card {
    width: min(100%, 300px);
    padding: 1.3rem 1.6rem 1.2rem;
    transform: translateY(8px) scale(.94);
    transition: transform .25s cubic-bezier(.34, 1.56, .64, 1);
    text-align: center;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
}
.net-title { margin: 0; display: flex; align-items: baseline; justify-content: center; gap: .1rem; font-weight: 600; color: var(--text); }
.net-dots { display: inline-flex; gap: 3px; margin-left: 2px; }
.net-dots i {
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: var(--primary);
    animation: net-dot 1.2s ease-in-out infinite;
}
.net-dots i:nth-child(2) { animation-delay: .15s; }
.net-dots i:nth-child(3) { animation-delay: .3s; }
@keyframes net-dot {
    0%, 70%, 100% { transform: translateY(0); opacity: .35; }
    35% { transform: translateY(-5px); opacity: 1; }
}
.net-sub { margin: .4rem 0 0; font-size: .9rem; color: var(--text-muted); }
.net-sub:empty { display: none; }
.net-actions { display: none; justify-content: center; gap: .6rem; margin-top: 1.1rem; }
.net-actions.is-visible { display: flex; }

.net-banner {
    position: fixed;
    left: 50%;
    bottom: calc(1rem + env(safe-area-inset-bottom, 0px));
    z-index: 1095;
    display: flex;
    align-items: center;
    gap: .6rem;
    max-width: calc(100vw - 2rem);
    padding: .7rem 1.1rem;
    font-size: .92rem;
    color: var(--text);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 999px;
    box-shadow: var(--shadow-md);
    transform: translate(-50%, 200%);
    transition: transform .25s ease;
}
.net-banner.is-visible { transform: translate(-50%, 0); }
.net-banner.is-offline { border-color: var(--danger); }
.net-banner.is-online { border-color: var(--success); }
.net-dot { flex: none; width: 10px; height: 10px; border-radius: 50%; background: var(--text-subtle); }
.net-banner.is-offline .net-dot { background: var(--danger); }
.net-banner.is-online .net-dot { background: var(--success); }
.net-banner.is-shake { animation: net-shake .4s ease; }

@keyframes net-spin { to { transform: rotate(360deg); } }
@keyframes net-shake {
    0%, 100% { transform: translate(-50%, 0); }
    25% { transform: translate(calc(-50% - 7px), 0); }
    75% { transform: translate(calc(-50% + 7px), 0); }
}
@media (prefers-reduced-motion: reduce) {
    .net-banner, .net-overlay, .net-bar, .net-bar > span { transition: none; }
    .net-banner.is-shake { animation: none; }
}

/* ===== Écran d'accueil animé (intro du logo) ===== */
.splash { display: none; }
html.splash-on .splash {
    position: fixed;
    inset: 0;
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg);
    animation: splash-out 2.7s ease forwards;
}
@keyframes splash-out {
    0%, 84% { opacity: 1; visibility: visible; }
    100% { opacity: 0; visibility: hidden; }
}
.splash-inner { display: flex; align-items: center; gap: clamp(.8rem, 2.5vw, 1.5rem); }
.splash-logo {
    flex: none;
    width: clamp(72px, 14vw, 112px);
    height: auto;
    overflow: visible;
    transform-origin: center;
    animation: splash-pop .75s cubic-bezier(.34, 1.56, .64, 1) both;
}
@keyframes splash-pop {
    from { transform: scale(.3) rotate(-14deg); opacity: 0; }
    to { transform: none; opacity: 1; }
}
.sl-ring {
    fill: none;
    stroke: #fff;
    stroke-width: 54;
    stroke-dasharray: 767;
    stroke-dashoffset: 767;
    transform: rotate(-90deg);
    transform-origin: 256px 256px;
    animation: sl-draw .8s cubic-bezier(.65, 0, .35, 1) .35s forwards;
}
@keyframes sl-draw { to { stroke-dashoffset: 0; } }
.sl-dot {
    transform: scale(0);
    transform-origin: 256px 256px;
    animation: sl-dot .45s cubic-bezier(.34, 1.56, .64, 1) 1.05s forwards;
}
@keyframes sl-dot { to { transform: scale(1); } }
.sl-shine { animation: sl-shine .75s ease 1.3s both; }
@keyframes sl-shine {
    from { transform: translateX(-220px) skewX(-20deg); }
    to { transform: translateX(640px) skewX(-20deg); }
}
.splash-word {
    display: flex;
    font-size: clamp(1.7rem, 5.2vw, 2.9rem);
    font-weight: 800;
    letter-spacing: .05em;
    color: var(--text);
}
.splash-word span {
    display: inline-block;
    opacity: 0;
    transform: translateY(.55em);
    animation: splash-letter .5s cubic-bezier(.2, .8, .2, 1) calc(.95s + var(--i, 0) * .055s) forwards;
}
.splash-word .light { font-weight: 400; color: var(--primary); }
.splash-word .sp { width: .32em; animation: none; }
@keyframes splash-letter { to { opacity: 1; transform: none; } }
@media (max-width: 480px) {
    .splash-inner { flex-direction: column; }
}
@media (prefers-reduced-motion: reduce) {
    html.splash-on .splash { animation-duration: 1.4s; }
    .splash-logo, .sl-dot, .sl-shine, .splash-word span { animation: none; opacity: 1; transform: none; }
    .sl-ring { animation: none; stroke-dashoffset: 0; }
    .sl-shine { display: none; }
}

/* ===== Chargeur personnalisé (logo qui respire et anneau qui tourne) ===== */
.net-logo { width: 62px; height: 62px; margin: 0 auto .8rem; border-radius: 16px; animation: net-glow 1.8s ease-in-out infinite; }
@keyframes net-glow {
    0%, 100% { box-shadow: 0 0 0 0 rgba(79, 70, 229, .45); }
    50% { box-shadow: 0 0 0 12px rgba(79, 70, 229, 0); }
}
.net-logo svg { display: block; width: 100%; height: 100%; overflow: visible; animation: net-breathe 1.8s ease-in-out infinite; }
.net-track { fill: none; stroke: #fff; stroke-opacity: .28; stroke-width: 54; }
.net-arc {
    fill: none;
    stroke: #fff;
    stroke-width: 54;
    stroke-linecap: round;
    stroke-dasharray: 210 557;
    transform-origin: 256px 256px;
    animation: net-orbit 1.1s linear infinite;
}
.net-core { transform-origin: 256px 256px; animation: net-beat 1.1s ease-in-out infinite; }
@keyframes net-orbit { to { transform: rotate(360deg); } }
@keyframes net-beat { 0%, 100% { transform: scale(.8); } 50% { transform: scale(1.25); } }
@keyframes net-breathe { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.06); } }
@media (prefers-reduced-motion: reduce) {
    .net-logo, .net-logo svg, .net-core, .net-dots i { animation: none; }
    .net-arc { animation-duration: 2.6s; }
}

/* ===== Commandes colorées : syntaxe, catégories, niveaux ===== */
:root {
    --sh-cmd: #4338ca; --sh-sudo: #b45309; --sh-sub: #0e7490; --sh-opt: #0369a1; --sh-str: #15803d;
    --sh-ph: #c2410c; --sh-var: #7e22ce; --sh-op: #be185d; --sh-path: #0f766e; --sh-num: #b45309; --sh-com: #8a8f9a;
    --cat-mix: #000;
}
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --sh-cmd: #a5b4fc; --sh-sudo: #fbbf24; --sh-sub: #22d3ee; --sh-opt: #38bdf8; --sh-str: #4ade80;
        --sh-ph: #fb923c; --sh-var: #c084fc; --sh-op: #f472b6; --sh-path: #2dd4bf; --sh-num: #fbbf24; --sh-com: #6b7280;
        --cat-mix: #fff;
    }
}
:root[data-theme="dark"] {
    --sh-cmd: #a5b4fc; --sh-sudo: #fbbf24; --sh-sub: #22d3ee; --sh-opt: #38bdf8; --sh-str: #4ade80;
    --sh-ph: #fb923c; --sh-var: #c084fc; --sh-op: #f472b6; --sh-path: #2dd4bf; --sh-num: #fbbf24; --sh-com: #6b7280;
    --cat-mix: #fff;
}

.sh-cmd { color: var(--sh-cmd); font-weight: 700; }
.sh-sudo { color: var(--sh-sudo); font-weight: 700; }
.sh-sub { color: var(--sh-sub); font-weight: 600; }
.sh-opt { color: var(--sh-opt); }
.sh-str { color: var(--sh-str); }
.sh-ph {
    color: var(--sh-ph);
    background: rgba(234, 88, 12, .12);
    background: color-mix(in srgb, var(--sh-ph) 14%, transparent);
    border-radius: 4px;
    padding: 0 .25em;
}
.sh-var { color: var(--sh-var); }
.sh-op { color: var(--sh-op); font-weight: 700; }
.sh-path { color: var(--sh-path); }
.sh-num { color: var(--sh-num); }
.sh-com { color: var(--sh-com); font-style: italic; }
code.sh { font-size: .88rem; }

/* Une couleur par catégorie (8 teintes) */
.cat-0 { --cat-color: #6366f1; } .cat-1 { --cat-color: #10b981; } .cat-2 { --cat-color: #f59e0b; } .cat-3 { --cat-color: #f43f5e; }
.cat-4 { --cat-color: #0ea5e9; } .cat-5 { --cat-color: #8b5cf6; } .cat-6 { --cat-color: #f97316; } .cat-7 { --cat-color: #14b8a6; }
.badge[class*="cat-"]:not(.cat-none) {
    background: rgba(99, 102, 241, .14);
    background: color-mix(in srgb, var(--cat-color) 15%, transparent);
    color: var(--cat-color);
    color: color-mix(in srgb, var(--cat-color) 62%, var(--cat-mix));
    border-color: transparent;
    font-weight: 600;
}
.card[class*="cat-"]:not(.cat-none) { border-left: 4px solid var(--cat-color); }
.filter-tab[class*="cat-"]:not(.cat-none) { display: inline-flex; align-items: center; gap: .45rem; }
.filter-tab[class*="cat-"]:not(.cat-none)::before {
    content: "";
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--cat-color);
}
.filter-tab[class*="cat-"]:not(.cat-none).active { background: var(--cat-color); border-color: var(--cat-color); }
.filter-tab[class*="cat-"]:not(.cat-none).active::before { background: #fff; }

/* Niveau : vert / orange / rouge */
.lv-beginner { --lv: var(--success); } .lv-intermediate { --lv: var(--warning); } .lv-advanced { --lv: var(--danger); }
.badge[class*="lv-"] {
    background: rgba(100, 100, 100, .12);
    background: color-mix(in srgb, var(--lv) 14%, transparent);
    color: var(--lv);
    border-color: transparent;
    font-weight: 600;
}

/* ===== Page d'accueil ===== */
.welcome-hero {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1.5rem;
    padding: clamp(1.25rem, 3vw, 2rem);
    color: #fff;
    background: linear-gradient(145deg, var(--primary-strong) 0%, var(--accent-2) 100%);
    border-radius: var(--radius-lg);
    box-shadow: 0 16px 40px -12px color-mix(in srgb, var(--primary) 65%, transparent), var(--shadow-md);
    overflow: hidden;
    isolation: isolate;
}
.welcome-hero::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: -1;
    background: radial-gradient(120% 140% at 100% 0%, rgba(255, 255, 255, .16), transparent 55%);
    pointer-events: none;
}
.welcome-hero-text { min-width: 0; }
.welcome-hero h1 { margin: .15rem 0 .5rem; font-size: clamp(1.5rem, 4vw, 2.1rem); color: #fff; }
.welcome-date { margin: 0; font-size: .85rem; opacity: .85; }
.welcome-date::first-letter { text-transform: uppercase; }
.welcome-summary { margin: 0 0 1.2rem; max-width: 46ch; font-size: 1.02rem; line-height: 1.5; opacity: .95; }
.welcome-actions { display: flex; flex-wrap: wrap; gap: .6rem; }
.welcome-hero .btn { background: #fff; color: var(--primary-strong); border-color: #fff; box-shadow: 0 2px 8px rgba(0, 0, 0, .15); }
/* filter, pas var(--primary-soft) : ce bouton reste sur le même dégradé vif quels que soient
   le thème et la couleur d'accent choisie, alors que --primary-soft devient un indigo
   translucide en mode sombre — sur fond déjà indigo, le texte y devenait quasi illisible. */
.welcome-hero .btn:hover { filter: brightness(.96); transform: translateY(-1px); }
.welcome-hero .btn-ghost { background: rgba(255, 255, 255, .08); color: #fff; border-color: rgba(255, 255, 255, .4); box-shadow: none; }
.welcome-hero .btn-ghost:hover { background: rgba(255, 255, 255, .18); transform: translateY(-1px); }
.welcome-logo { flex: none; width: clamp(72px, 12vw, 120px); box-shadow: 0 8px 24px rgba(0, 0, 0, .25); border-radius: 26%; }
.welcome-section { margin-top: 1.75rem; }
.welcome-section h2 { margin: 0 0 .75rem; font-size: 1.05rem; }

.welcome-today { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: minmax(0, 1fr); gap: .5rem; }
.welcome-today li { min-width: 0; }
.welcome-today a {
    display: flex;
    align-items: center;
    gap: .8rem;
    padding: .7rem 1rem;
    text-decoration: none;
    color: var(--text);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    transition: border-color .15s ease, transform .15s ease;
}
.welcome-today a:hover { border-color: var(--primary); transform: translateY(-1px); }
.welcome-today-time { min-width: 3.4rem; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--primary); }
.welcome-today-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.welcome-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: .8rem; }
.welcome-tile {
    display: flex;
    flex-direction: column;
    gap: .15rem;
    padding: 1rem;
    text-decoration: none;
    color: var(--text);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    transition: transform .18s cubic-bezier(.2, .8, .2, 1), box-shadow .18s ease, border-color .18s ease;
}
.welcome-tile:hover {
    transform: translateY(-3px);
    box-shadow: 0 12px 24px -8px color-mix(in srgb, var(--cat-color, var(--primary)) 45%, transparent), var(--shadow-md);
    border-color: color-mix(in srgb, var(--cat-color, var(--primary)) 55%, var(--border));
}
.welcome-tile:active { transform: translateY(-1px) scale(.98); }
.welcome-tile-icon {
    display: grid;
    place-items: center;
    width: 40px;
    height: 40px;
    margin-bottom: .5rem;
    color: #fff;
    background: linear-gradient(150deg, color-mix(in srgb, var(--cat-color, var(--primary)) 92%, #fff 8%), color-mix(in srgb, var(--cat-color, var(--primary)) 70%, #000 18%));
    border-radius: 12px;
    box-shadow: 0 4px 10px -3px color-mix(in srgb, var(--cat-color, var(--primary)) 65%, transparent);
}
.welcome-tile-label { font-weight: 600; }
.welcome-tile-count { font-size: .85rem; color: var(--text-muted); }

.welcome-guest { display: flex; flex-direction: column; align-items: center; text-align: center; padding: 2.5rem 1rem; }
.welcome-guest .splash-logo { animation-delay: 0s; }
.welcome-guest h1 { margin: 1.1rem 0 .4rem; font-size: clamp(1.8rem, 6vw, 2.8rem); font-weight: 800; letter-spacing: .04em; white-space: nowrap; }
.welcome-guest .light { font-weight: 400; color: var(--primary); }
.welcome-tagline { margin: 0 0 1.5rem; max-width: 36ch; font-size: 1.05rem; color: var(--text-muted); }
.welcome-login { padding: .8rem 2.2rem; font-size: 1rem; }
.welcome-features { display: flex; flex-wrap: wrap; justify-content: center; gap: .6rem; margin: 2rem 0 0; padding: 0; list-style: none; }
.welcome-features li {
    display: inline-flex;
    align-items: center;
    gap: .5rem;
    padding: .5rem .9rem;
    font-size: .9rem;
    color: var(--cat-color);
    background: rgba(99, 102, 241, .12);
    background: color-mix(in srgb, var(--cat-color) 12%, transparent);
    border-radius: 999px;
}
@media (max-width: 560px) {
    .welcome-hero { flex-direction: column-reverse; align-items: flex-start; }
}

/* La règle générique des champs de formulaire écrasait le retrait à gauche : la loupe cachait la 1re lettre. */
form.search-box input[type="search"] { padding-left: 2.2rem; }

/* Mobile : les lignes du programme passent sur deux lignes (heure + titre, puis badge) au lieu de déborder */
@media (max-width: 560px) {
    .welcome-today a {
        display: grid;
        grid-template-columns: auto minmax(0, 1fr);
        align-items: start;
        gap: .25rem .75rem;
    }
    .welcome-today-title { white-space: normal; overflow: visible; text-overflow: clip; overflow-wrap: anywhere; }
    .welcome-today .badge { grid-column: 2; justify-self: start; min-width: 0; max-width: 100%; white-space: normal; }
}
@media (max-width: 480px) {
    .welcome-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .6rem; }
    .welcome-tile { padding: .85rem; }
    .welcome-hero .btn { width: 100%; justify-content: center; }
    .welcome-actions { width: 100%; }
}


/* ===== Logo de marque ===== */
.brand-logo { flex: none; width: 28px; height: 28px; border-radius: 8px; }
.auth-card .brand-logo { width: 36px; height: 36px; border-radius: 10px; }

/* ===== Formulaires : la date et l'heure côte à côte ===== */
form.styled-form { display: grid; grid-template-columns: 1fr 1fr; column-gap: 1rem; align-items: start; }
form.styled-form > * { grid-column: 1 / -1; }
form.styled-form > p:has(+ p input[type="time"]),
form.styled-form > p:has(input[type="time"]) { grid-column: auto; }
@media (max-width: 420px) {
    form.styled-form { grid-template-columns: 1fr; }
    form.styled-form > p:has(+ p input[type="time"]),
    form.styled-form > p:has(input[type="time"]) { grid-column: 1 / -1; }
}


/* ===== Priorités, difficultés, tags, barres de progression ===== */
.pr-low { --pr: var(--text-muted); } .pr-normal { --pr: #0ea5e9; } .pr-high { --pr: var(--warning); } .pr-urgent { --pr: var(--danger); }
.badge[class*="pr-"] {
    background: rgba(100, 100, 100, .12);
    background: color-mix(in srgb, var(--pr) 14%, transparent);
    color: var(--pr);
    border-color: transparent;
    font-weight: 600;
}
.badge.pr-urgent { font-weight: 700; }
.badge.pr-urgent::before { content: ""; width: 6px; height: 6px; margin-right: .4rem; border-radius: 50%; background: var(--pr); animation: net-glow-dot 1.4s ease-in-out infinite; }
@keyframes net-glow-dot { 0%, 100% { opacity: 1; } 50% { opacity: .3; } }
.card[class*="pr-"] { border-left: 4px solid var(--pr); }
.card.err { border-left: 4px solid var(--danger); }
.tag-line { display: inline-flex; flex-wrap: wrap; gap: .3rem; }
.progress-bar span { background: linear-gradient(90deg, var(--primary), var(--primary-hover)); transition: width .6s cubic-bezier(.2, .8, .2, 1); }
.progress-bar span.is-complete { background: var(--success); }


/* ===== Mobile : navigation en bas + bouton « + » d'ajout rapide ===== */
.fab-checkbox { position: absolute; opacity: 0; pointer-events: none; }
.bottom-nav, .fab-backdrop, .fab-sheet { display: none; }
@media (max-width: 767px) {
    .bottom-nav {
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 60;
        display: grid;
        grid-template-columns: repeat(5, 1fr);
        align-items: end;
        padding: .3rem .25rem calc(.3rem + env(safe-area-inset-bottom, 0px));
        background: var(--surface);
        border-top: 1px solid var(--border);
        box-shadow: 0 -4px 16px rgba(15, 23, 42, .06);
        transition: transform .25s ease;
    }
    :root[data-theme="dark"] .bottom-nav {
        background: color-mix(in srgb, var(--surface) 90%, transparent);
        -webkit-backdrop-filter: blur(12px);
        backdrop-filter: blur(12px);
        box-shadow: 0 -4px 20px rgba(0, 0, 0, .35);
    }
    @media (prefers-color-scheme: dark) {
        :root:not([data-theme="light"]) .bottom-nav {
            background: color-mix(in srgb, var(--surface) 90%, transparent);
            -webkit-backdrop-filter: blur(12px);
            backdrop-filter: blur(12px);
            box-shadow: 0 -4px 20px rgba(0, 0, 0, .35);
        }
    }
    .nav-toggle-checkbox:checked ~ .bottom-nav { transform: translateY(110%); }
    .bn-link {
        position: relative;
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: .15rem;
        min-height: 48px;
        padding: .35rem 0 .2rem;
        font-size: .7rem;
        color: var(--text-muted);
        text-decoration: none;
        cursor: pointer;
        -webkit-tap-highlight-color: transparent;
    }
    .bn-link.active { color: var(--primary); font-weight: 700; }
    .bn-link.active::before {
        content: "";
        position: absolute;
        top: -.3rem;
        width: 26px;
        height: 3px;
        border-radius: 0 0 3px 3px;
        background: var(--primary);
    }
    .bn-link:active { transform: scale(.94); }
    .bn-fab {
        justify-self: center;
        display: grid;
        place-items: center;
        width: 56px;
        height: 56px;
        margin-top: -24px;
        color: #fff;
        background: linear-gradient(135deg, var(--primary-strong), var(--accent-2));
        border-radius: 50%;
        box-shadow: 0 8px 20px -2px color-mix(in srgb, var(--primary) 55%, transparent), 0 2px 6px rgba(0, 0, 0, .2);
        cursor: pointer;
        transition: transform .2s cubic-bezier(.34, 1.56, .64, 1), box-shadow .2s ease;
        -webkit-tap-highlight-color: transparent;
    }
    .bn-fab .icon { width: 26px; height: 26px; }
    .bn-fab:active { transform: scale(.92); }
    .fab-checkbox:checked ~ .bottom-nav .bn-fab { transform: rotate(135deg); }

    .fab-backdrop {
        display: block;
        position: fixed;
        inset: 0;
        z-index: 58;
        background: rgba(0, 0, 0, .4);
        opacity: 0;
        visibility: hidden;
        transition: opacity .2s ease, visibility .2s;
    }
    .fab-checkbox:checked ~ .fab-backdrop { opacity: 1; visibility: visible; }
    .fab-sheet {
        position: fixed;
        left: .75rem;
        right: .75rem;
        bottom: calc(88px + env(safe-area-inset-bottom, 0px));
        z-index: 59;
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: .5rem;
        padding: .75rem;
        background: var(--surface);
        border: 1px solid var(--border);
        border-radius: var(--radius-lg);
        box-shadow: var(--shadow-md);
        opacity: 0;
        visibility: hidden;
        transform: translateY(16px) scale(.96);
        transition: opacity .2s ease, transform .25s cubic-bezier(.34, 1.56, .64, 1), visibility .2s;
    }
    .fab-checkbox:checked ~ .fab-sheet { opacity: 1; visibility: visible; transform: none; }
    .fab-sheet a {
        display: flex;
        align-items: center;
        gap: .6rem;
        min-height: 46px;
        padding: .6rem .8rem;
        font-size: .92rem;
        font-weight: 600;
        color: var(--text);
        text-decoration: none;
        background: var(--bg);
        border-radius: var(--radius-md);
    }
    .fab-sheet a .icon { color: var(--cat-color); }
    .fab-sheet a:active { transform: scale(.97); }

    .page { padding-bottom: calc(6rem + env(safe-area-inset-bottom, 0px)); }
    .net-banner { bottom: calc(5.5rem + env(safe-area-inset-bottom, 0px)); }
}


/* ===== Graphiques du tableau de bord ===== */
.viz { margin-bottom: 1.25rem; }
.kpi-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: .8rem; margin-bottom: 1rem; }
.kpi { display: flex; flex-direction: column; gap: .15rem; padding: 1rem 1.1rem; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); box-shadow: var(--shadow-sm); }
.kpi-label { font-size: .8rem; color: var(--text-muted); }
.kpi-value { font-size: 1.9rem; font-weight: 700; line-height: 1.15; color: var(--text); }
.kpi-value small { font-size: .9rem; font-weight: 500; color: var(--text-muted); }
.kpi-note { font-size: .8rem; color: var(--text-muted); }
.kpi-delta { font-weight: 700; }
.kpi-delta.is-up { color: var(--success); }
.kpi-delta.is-down { color: var(--danger); }

/* Colonnes : 24 px maximum, extrémité arrondie, base carrée, repères en filet fin */
.col-chart { display: grid; grid-template-columns: auto 1fr; gap: .5rem; margin-top: .75rem; }
.col-y { display: flex; flex-direction: column; justify-content: space-between; height: 148px; margin-top: 0; font-size: .72rem; color: var(--text-subtle); text-align: right; font-variant-numeric: tabular-nums; }
.col-plot {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    height: 170px;
    position: relative;
    background:
        linear-gradient(var(--border), var(--border)) 0 0 / 100% 1px no-repeat,
        linear-gradient(var(--border), var(--border)) 0 74px / 100% 1px no-repeat,
        linear-gradient(var(--border), var(--border)) 0 148px / 100% 1px no-repeat;
}
.col-item { position: relative; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; height: 100%; outline: none; }
.col-bar {
    position: relative;
    display: block;
    width: min(24px, 60%);
    height: calc(148px * var(--h, 0) / 100);
    min-height: 0;
    background: rgba(79, 70, 229, .4);
    background: color-mix(in srgb, var(--primary) 42%, var(--surface));
    border-radius: 4px 4px 0 0;
    transition: background .15s ease, height .5s cubic-bezier(.2, .8, .2, 1);
}
.col-item.is-today .col-bar, .col-item:hover .col-bar, .col-item:focus-visible .col-bar { background: var(--primary); }
.col-val { position: absolute; left: 50%; bottom: calc(100% + 3px); transform: translateX(-50%); font-size: .72rem; font-weight: 700; color: var(--text); white-space: nowrap; }
.col-x { height: 22px; padding-top: 5px; font-size: .72rem; color: var(--text-muted); }
.col-item.is-today .col-x { color: var(--text); font-weight: 700; }
.col-bar::after {
    content: attr(data-tip);
    position: absolute;
    left: 50%;
    bottom: calc(100% + 22px);
    transform: translateX(-50%);
    padding: .3rem .55rem;
    font-size: .74rem;
    font-weight: 600;
    white-space: nowrap;
    color: var(--text);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: var(--shadow-md);
    opacity: 0;
    pointer-events: none;
    z-index: 5;
    transition: opacity .12s ease;
}
.col-item:hover .col-bar::after, .col-item:focus-visible .col-bar::after { opacity: 1; }
.col-item:first-child .col-bar::after { left: 0; transform: none; }
.col-item:last-child .col-bar::after { left: auto; right: 0; transform: none; }

.viz-table { margin-top: .8rem; font-size: .85rem; }
.viz-table summary { cursor: pointer; color: var(--text-muted); }
.viz-table table { width: 100%; margin-top: .5rem; border-collapse: collapse; }
.viz-table th, .viz-table td { padding: .3rem .4rem; text-align: left; border-bottom: 1px solid var(--border); }
.viz-table td:last-child, .viz-table th:last-child { text-align: right; font-variant-numeric: tabular-nums; }

/* Répartition : une teinte en trois intensités, 2 px de vide entre les segments */
.stack { display: flex; gap: 2px; height: 14px; margin: .9rem 0 .6rem; }
.stack-seg { min-width: 6px; }
.stack-seg:first-child { border-radius: 4px 0 0 4px; }
.stack-seg:last-child { border-radius: 0 4px 4px 0; }
.stack-seg:only-child { border-radius: 4px; }
.tone-1 { background: rgba(79, 70, 229, .22); background: color-mix(in srgb, var(--primary) 24%, var(--surface)); }
.tone-2 { background: rgba(79, 70, 229, .6); background: color-mix(in srgb, var(--primary) 60%, var(--surface)); }
.tone-3 { background: var(--primary); }
.legend { display: flex; flex-wrap: wrap; gap: .3rem 1rem; margin: 0 0 1.1rem; padding: 0; list-style: none; font-size: .82rem; color: var(--text-muted); }
.legend b { color: var(--text); }
.sw { display: inline-block; width: 10px; height: 10px; margin-right: .4rem; border-radius: 3px; }

/* Mètres : le rail est un cran plus clair de la même teinte */
.meters { display: grid; gap: .75rem; margin: 0; padding: 0; list-style: none; }
.meters li { display: grid; grid-template-columns: 1fr auto; gap: .25rem .75rem; align-items: baseline; }
.meter-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .88rem; }
.meter-val { font-size: .82rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.meter { grid-column: 1 / -1; height: 8px; overflow: hidden; background: var(--primary-soft); border-radius: 999px; }
.meter > span { display: block; width: var(--pct, 0%); height: 100%; background: var(--primary); border-radius: 999px; transition: width .6s cubic-bezier(.2, .8, .2, 1); }
.meter > span.is-complete { background: var(--success); }
@media (prefers-reduced-motion: reduce) { .col-bar, .meter > span { transition: none; } }
.panel-header .btn { white-space: nowrap; }


/* ===== Calendrier : onglets et vue journée ===== */
.view-tabs { display: inline-flex; gap: 2px; margin-bottom: 1rem; padding: 3px; background: var(--bg); border: 1px solid var(--border); border-radius: 999px; }
.view-tab { padding: .3rem 1rem; font-size: .85rem; font-weight: 600; text-decoration: none; color: var(--text-muted); border-radius: 999px; }
.view-tab.active { color: var(--on-primary); background: var(--primary); }
a.day-number { text-decoration: none; color: inherit; }
a.day-number:hover { text-decoration: underline; }
.day-title { margin: 0; text-transform: capitalize; font-size: 1.25rem; }
.agenda-allday { display: flex; align-items: flex-start; gap: .75rem; margin-bottom: 1rem; padding: .7rem .9rem; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); }
.agenda-label { flex: none; min-width: 3.2rem; font-size: .78rem; font-weight: 700; color: var(--text-muted); }
.agenda-chips { display: flex; flex-wrap: wrap; gap: .35rem; min-width: 0; }
.agenda-chips .calendar-event { display: inline-block; max-width: 100%; padding: .2rem .6rem; font-size: .82rem; }
.agenda-empty { margin: .5rem 0 1rem; color: var(--text-muted); }
.agenda { position: relative; margin-left: 3.2rem; border-top: 1px solid var(--border); }
.agenda-hour { position: absolute; left: -3.2rem; right: 0; height: var(--hour-px); border-top: 1px solid var(--border); }
.agenda-hour:first-child { border-top: 0; }
.agenda-hour span { position: absolute; top: -.6rem; left: 0; width: 2.6rem; font-size: .72rem; text-align: right; color: var(--text-subtle); font-variant-numeric: tabular-nums; background: var(--bg); }
.agenda-events { position: absolute; inset: 0; }
.agenda-event {
    position: absolute;
    display: flex;
    align-items: center;
    min-width: 0;
    padding: .2rem .5rem;
    overflow: hidden;
    font-size: .8rem;
    line-height: 1.25;
    text-decoration: none;
    white-space: nowrap;
    border-left: 3px solid currentColor;
    border-radius: 6px;
    box-sizing: border-box;
}
/* Un créneau court (par défaut 30 min pour une tâche/un objectif sans durée propre) ne
   laisse la place que pour une ligne : on tronque plutôt que de couper le texte au milieu
   d'un mot (le titre complet reste dans l'attribut title, au survol ou en vocalisation). */
.agenda-event strong { flex: none; margin-right: .3rem; font-variant-numeric: tabular-nums; }
.agenda-event span { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; color: var(--text); }
.agenda-now { position: absolute; left: -3.2rem; right: 0; height: 2px; background: var(--danger); z-index: 3; }
.agenda-now::before { content: ""; position: absolute; left: 2.6rem; top: -4px; width: 10px; height: 10px; border-radius: 50%; background: var(--danger); }


/* ===== Texte enrichi : code coloré dans les fiches et les erreurs ===== */
.rich-code { position: relative; margin: 1rem 0; }
.rich-code pre { margin: 0; padding-top: 1.7rem; padding-right: 2.75rem; }
.rich-code::before {
    content: attr(data-lang);
    position: absolute;
    top: .4rem;
    left: .8rem;
    font-size: .68rem;
    font-weight: 700;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--text-subtle);
}
.rich-code .copy-btn { position: absolute; top: .4rem; right: .4rem; }
.detail-body p { margin: 0 0 .9rem; }
.detail-body ul { margin: 0 0 .9rem; padding-left: 1.3rem; }
code.inline { padding: .1rem .4rem; font-size: .88em; color: var(--sh-cmd); background: var(--primary-soft); border-radius: 5px; }
.cd-kw { color: var(--sh-var); font-weight: 600; }
.cd-str { color: var(--sh-str); }
.cd-num { color: var(--sh-num); }
.cd-fn { color: var(--sh-cmd); }
.cd-com { color: var(--sh-com); font-style: italic; }
pre.error-message { color: var(--danger); background: var(--danger-soft); border-color: transparent; border-left: 4px solid var(--danger); white-space: pre-wrap; word-break: break-word; }

/* ===== Couleur principale au choix (l'indigo est la valeur par défaut) ===== */
:root[data-accent="violet"] { --primary: #7c3aed; --primary-hover: #6d28d9; --primary-soft: #f1eaff; --primary-strong: #7c3aed; --accent-2: #a21caf; --on-primary: #fff; }
:root[data-accent="rose"] { --primary: #e11d48; --primary-hover: #be123c; --primary-soft: #ffe8ee; --primary-strong: #e11d48; --accent-2: #c2410c; --on-primary: #fff; }
:root[data-accent="orange"] { --primary: #c2410c; --primary-hover: #9a3412; --primary-soft: #ffeee2; --primary-strong: #c2410c; --accent-2: #be123c; --on-primary: #fff; }
:root[data-accent="emerald"] { --primary: #047857; --primary-hover: #065f46; --primary-soft: #e3f7ee; --primary-strong: #047857; --accent-2: #0f766e; --on-primary: #fff; }
:root[data-accent="teal"] { --primary: #0f766e; --primary-hover: #115e59; --primary-soft: #e0f5f3; --primary-strong: #0f766e; --accent-2: #0369a1; --on-primary: #fff; }
@media (prefers-color-scheme: dark) {
    :root[data-accent="violet"]:not([data-theme="light"]) { --primary: #a78bfa; --primary-hover: #c4b5fd; --primary-soft: rgba(167,139,250,.18); --on-primary: #0b0d12; }
    :root[data-accent="rose"]:not([data-theme="light"]) { --primary: #fb7185; --primary-hover: #fda4af; --primary-soft: rgba(251,113,133,.18); --on-primary: #0b0d12; }
    :root[data-accent="orange"]:not([data-theme="light"]) { --primary: #fb923c; --primary-hover: #fdba74; --primary-soft: rgba(251,146,60,.18); --on-primary: #0b0d12; }
    :root[data-accent="emerald"]:not([data-theme="light"]) { --primary: #34d399; --primary-hover: #6ee7b7; --primary-soft: rgba(52,211,153,.16); --on-primary: #0b0d12; }
    :root[data-accent="teal"]:not([data-theme="light"]) { --primary: #2dd4bf; --primary-hover: #5eead4; --primary-soft: rgba(45,212,191,.16); --on-primary: #0b0d12; }
}
:root[data-accent="violet"][data-theme="dark"] { --primary: #a78bfa; --primary-hover: #c4b5fd; --primary-soft: rgba(167,139,250,.18); --on-primary: #0b0d12; }
:root[data-accent="rose"][data-theme="dark"] { --primary: #fb7185; --primary-hover: #fda4af; --primary-soft: rgba(251,113,133,.18); --on-primary: #0b0d12; }
:root[data-accent="orange"][data-theme="dark"] { --primary: #fb923c; --primary-hover: #fdba74; --primary-soft: rgba(251,146,60,.18); --on-primary: #0b0d12; }
:root[data-accent="emerald"][data-theme="dark"] { --primary: #34d399; --primary-hover: #6ee7b7; --primary-soft: rgba(52,211,153,.16); --on-primary: #0b0d12; }
:root[data-accent="teal"][data-theme="dark"] { --primary: #2dd4bf; --primary-hover: #5eead4; --primary-soft: rgba(45,212,191,.16); --on-primary: #0b0d12; }

/* ===== Réglages dans le menu : un seul menu déroulant (couleur, thème, sauvegardes, admin) ===== */
.sidebar-settings {
    border-top: 1px solid var(--border);
    margin-top: .5rem;
    padding-top: .35rem;
    padding-bottom: .25rem;
}
.setting-summary {
    list-style: none;
    cursor: pointer;
}
.setting-summary::-webkit-details-marker { display: none; }
.setting-summary .setting-chevron { margin-left: auto; color: var(--text-subtle); transition: transform .2s ease; }
.sidebar-settings[open] .setting-summary .setting-chevron { transform: rotate(90deg); }
.sidebar-settings-body { padding-top: .3rem; display: flex; flex-direction: column; gap: .15rem; }
.setting-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .6rem;
    width: 100%;
    padding: .5rem .6rem;
    color: inherit;
    font: inherit;
    background: none;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
}
.setting-label { display: inline-flex; align-items: center; gap: .6rem; font-size: .9rem; color: var(--text); }
button.setting-row:hover { background: var(--surface-hover); }

.setting-block-label { margin: 0 0 .5rem; padding: .5rem .6rem 0; }
.accent-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: .4rem;
    margin-bottom: .75rem;
    padding: 0 .6rem;
}
.accent-swatch {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: .3rem;
    min-height: 44px;
    padding: .5rem .25rem;
    color: var(--text-muted);
    font: inherit;
    background: none;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: border-color .15s ease, background .15s ease;
}
.accent-swatch:hover { background: var(--surface-hover); }
.accent-swatch.is-active {
    color: var(--text);
    border-color: color-mix(in srgb, var(--dot) 45%, var(--border));
    background: color-mix(in srgb, var(--dot) 12%, var(--surface-hover));
    font-weight: 600;
}
.accent-swatch-dot {
    display: grid;
    place-items: center;
    width: 26px;
    height: 26px;
    color: #fff;
    background: var(--dot);
    border-radius: 50%;
    box-shadow: 0 0 0 2px var(--surface), 0 0 0 3px var(--border);
    transition: transform .15s cubic-bezier(.34, 1.56, .64, 1);
}
.accent-swatch:hover .accent-swatch-dot { transform: scale(1.08); }
.accent-swatch.is-active .accent-swatch-dot { box-shadow: 0 0 0 2px var(--surface), 0 0 0 3px var(--dot), 0 4px 10px -2px color-mix(in srgb, var(--dot) 65%, transparent); }
.accent-swatch-dot .icon {
    width: 13px;
    height: 13px;
    vertical-align: 0;
    opacity: 0;
    transform: scale(.4);
    transition: opacity .15s ease, transform .15s cubic-bezier(.34, 1.56, .64, 1);
}
.accent-swatch.is-active .accent-swatch-dot .icon { opacity: 1; transform: none; }
.accent-swatch-name { font-size: .68rem; line-height: 1.1; text-align: center; }
@media (prefers-reduced-motion: reduce) { .accent-swatch-dot, .accent-swatch-dot .icon { transition: none; } }

.setting-switch {
    flex: none;
    width: 34px;
    height: 20px;
    padding: 2px;
    background: var(--border);
    border-radius: 999px;
    transition: background .2s ease;
}
.setting-switch-knob {
    display: block;
    width: 16px;
    height: 16px;
    background: #fff;
    border-radius: 50%;
    box-shadow: var(--shadow-sm);
    transition: transform .2s cubic-bezier(.34, 1.56, .64, 1);
}
:root[data-theme="dark"] .setting-switch { background: var(--primary); }
:root[data-theme="dark"] .setting-switch-knob { transform: translateX(14px); }
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .setting-switch { background: var(--primary); }
    :root:not([data-theme="light"]) .setting-switch-knob { transform: translateX(14px); }
}
@media (prefers-reduced-motion: reduce) { .setting-switch, .setting-switch-knob { transition: none; } }

.agenda-chips .calendar-event { width: auto; flex: none; }


/* ===== Animations : apparition en cascade, validation d'une tâche, transition entre pages ===== */
@keyframes rise { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
.card-list > li, .panel-list > li, .welcome-today > li, .welcome-tiles > a, .kpi-row > .kpi, .stats > .stat-card {
    animation: rise .45s cubic-bezier(.2, .8, .2, 1) backwards;
    animation-delay: calc(var(--i, 0) * 40ms);
}
.card-list > li:nth-child(1), .panel-list > li:nth-child(1), .welcome-today > li:nth-child(1), .welcome-tiles > a:nth-child(1), .kpi-row > .kpi:nth-child(1), .stats > .stat-card:nth-child(1) { --i: 0; }
.card-list > li:nth-child(2), .panel-list > li:nth-child(2), .welcome-today > li:nth-child(2), .welcome-tiles > a:nth-child(2), .kpi-row > .kpi:nth-child(2), .stats > .stat-card:nth-child(2) { --i: 1; }
.card-list > li:nth-child(3), .panel-list > li:nth-child(3), .welcome-today > li:nth-child(3), .welcome-tiles > a:nth-child(3), .kpi-row > .kpi:nth-child(3), .stats > .stat-card:nth-child(3) { --i: 2; }
.card-list > li:nth-child(4), .panel-list > li:nth-child(4), .welcome-today > li:nth-child(4), .welcome-tiles > a:nth-child(4), .kpi-row > .kpi:nth-child(4), .stats > .stat-card:nth-child(4) { --i: 3; }
.card-list > li:nth-child(5), .panel-list > li:nth-child(5), .welcome-today > li:nth-child(5), .welcome-tiles > a:nth-child(5), .kpi-row > .kpi:nth-child(5), .stats > .stat-card:nth-child(5) { --i: 4; }
.card-list > li:nth-child(6), .panel-list > li:nth-child(6), .welcome-today > li:nth-child(6), .welcome-tiles > a:nth-child(6), .kpi-row > .kpi:nth-child(6), .stats > .stat-card:nth-child(6) { --i: 5; }
.card-list > li:nth-child(7), .panel-list > li:nth-child(7), .welcome-today > li:nth-child(7), .welcome-tiles > a:nth-child(7), .kpi-row > .kpi:nth-child(7), .stats > .stat-card:nth-child(7) { --i: 6; }
.card-list > li:nth-child(8), .panel-list > li:nth-child(8), .welcome-today > li:nth-child(8), .welcome-tiles > a:nth-child(8), .kpi-row > .kpi:nth-child(8), .stats > .stat-card:nth-child(8) { --i: 7; }
.card-list > li:nth-child(9), .panel-list > li:nth-child(9), .welcome-today > li:nth-child(9), .welcome-tiles > a:nth-child(9), .kpi-row > .kpi:nth-child(9), .stats > .stat-card:nth-child(9) { --i: 8; }
.card-list > li:nth-child(10), .panel-list > li:nth-child(10), .welcome-today > li:nth-child(10), .welcome-tiles > a:nth-child(10), .kpi-row > .kpi:nth-child(10), .stats > .stat-card:nth-child(10) { --i: 9; }
.card-list > li:nth-child(11), .panel-list > li:nth-child(11), .welcome-today > li:nth-child(11), .welcome-tiles > a:nth-child(11), .kpi-row > .kpi:nth-child(11), .stats > .stat-card:nth-child(11) { --i: 10; }
.card-list > li:nth-child(12), .panel-list > li:nth-child(12), .welcome-today > li:nth-child(12), .welcome-tiles > a:nth-child(12), .kpi-row > .kpi:nth-child(12), .stats > .stat-card:nth-child(12) { --i: 11; }

.btn:active, .icon-action:active { transform: scale(.95); }
.icon-action { position: relative; }

.icon-action.is-checking { color: var(--success); background: var(--success-soft); animation: checkPop .42s cubic-bezier(.34, 1.56, .64, 1); }
@keyframes checkPop { 0% { transform: scale(1); } 45% { transform: scale(1.35) rotate(-8deg); } 100% { transform: scale(1); } }
.card.is-completing .card-title {
    color: var(--text-muted);
    background: linear-gradient(currentColor, currentColor) no-repeat 0 58% / 0% 2px;
    animation: strike .4s ease forwards;
}
@keyframes strike { to { background-size: 100% 2px; } }
.burst-dot {
    position: absolute;
    left: 50%;
    top: 50%;
    width: 6px;
    height: 6px;
    margin: -3px 0 0 -3px;
    background: var(--dot, var(--success));
    border-radius: 50%;
    pointer-events: none;
    animation: burst .55s ease-out forwards;
}
@keyframes burst { from { opacity: 1; transform: translate(0, 0) scale(1); } to { opacity: 0; transform: translate(var(--dx), var(--dy)) scale(.3); } }

@view-transition { navigation: auto; }
.topbar { view-transition-name: oswel-topbar; }
.bottom-nav { view-transition-name: oswel-bottom-nav; }
@media (min-width: 768px) { .sidebar { view-transition-name: oswel-sidebar; } }
::view-transition-old(root), ::view-transition-new(root) { animation-duration: .18s; }
@media (prefers-reduced-motion: reduce) {
    @view-transition { navigation: none; }
    .empty-state .icon, .burst-dot { animation: none; }
    .card-list > li, .panel-list > li, .welcome-today > li, .welcome-tiles > a, .kpi-row > .kpi, .stats > .stat-card { animation: none; }
}

/* ===== Accessibilité : focus visible, lien d'accès au contenu, zones tactiles, contraste renforcé ===== */
:where(a, button, input, select, textarea, summary, [tabindex]):focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}
.skip-link {
    position: absolute;
    top: -4rem;
    left: .75rem;
    z-index: 3000;
    padding: .6rem 1rem;
    color: var(--on-primary);
    font-weight: 600;
    text-decoration: none;
    background: var(--primary);
    border-radius: var(--radius-md);
    transition: top .15s ease;
}
.skip-link:focus { top: .75rem; }
@media (pointer: coarse) {
    .icon-action, .icon-btn, .sidebar-close { min-width: 44px; min-height: 44px; }
    .icon-action { width: 44px; height: 44px; }
    .btn, .btn-sm { min-height: 44px; }
    .filter-tab { display: inline-flex; align-items: center; min-height: 40px; }
    .nav-link { min-height: 44px; }
    form input:not([type="checkbox"]):not([type="radio"]), form select, form textarea { min-height: 44px; font-size: 16px; }
}
@media (prefers-contrast: more) {
    :root { --border: #7a808c; --text-muted: #3a3f47; --text-subtle: #454a52; }
}
@media (prefers-contrast: more) and (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) { --border: #7a808c; --text-muted: #d3d7de; --text-subtle: #c4c9d1; }
}

/* ===== Sauvegardes ===== */
.backup-intro { margin: -.25rem 0 1rem; }
.backup-alert, .backup-ok { display: flex; align-items: flex-start; gap: .75rem; margin-bottom: 1rem; padding: .85rem 1rem; font-size: .92rem; line-height: 1.45; border-radius: var(--radius-md); }
.backup-alert { color: var(--text); background: var(--warning-soft); border: 1px solid var(--warning); }
.backup-alert .icon { color: var(--warning); margin-top: 2px; }
.backup-ok { color: var(--text); background: var(--success-soft); border: 1px solid var(--success); }
.backup-ok .icon { color: var(--success); margin-top: 2px; }
.backup-grid { margin-bottom: 1rem; }
.backup-counts { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: .4rem .8rem; margin: .5rem 0 1rem; padding: 0; list-style: none; font-size: .9rem; }
.backup-counts b { font-size: 1.05rem; color: var(--primary); font-variant-numeric: tabular-nums; }
.backup-files { display: flex; align-items: center; gap: .5rem; margin: 0; font-size: .85rem; }
.backup-actions { display: flex; flex-wrap: wrap; gap: .6rem; margin: .5rem 0 .9rem; }
.backup-note { margin: 0; font-size: .82rem; line-height: 1.5; }
.backup-list, .backup-restore { margin-bottom: 1rem; }
.backup-when { flex: 1; min-width: 9rem; font-variant-numeric: tabular-nums; }
.backup-size { min-width: 4.5rem; font-size: .82rem; text-align: right; }
.backup-restore-form { display: flex; flex-wrap: wrap; align-items: center; gap: .75rem 1rem; }
.backup-restore-form input[type="file"] { max-width: 100%; font-size: .85rem; }
.backup-confirm { display: inline-flex; align-items: center; gap: .45rem; font-size: .88rem; }
@media (max-width: 480px) {
    .backup-actions .btn, .backup-actions form, .backup-restore-form .btn { width: 100%; }
    .backup-actions .btn, .backup-restore-form .btn { justify-content: center; }
    .backup-list .panel-list li { flex-wrap: wrap; }
}

/* ===== Mode révision ===== */
.quiz-head { display: flex; align-items: center; justify-content: space-between; gap: .75rem; margin-bottom: 1rem; }
.quiz-quit { display: inline-flex; align-items: center; gap: .35rem; color: var(--text-muted); text-decoration: none; font-size: .88rem; }
.quiz-quit:hover { color: var(--danger); }
.quiz-card {
    width: min(100%, 620px);
    margin: 0 auto;
    padding: clamp(1.5rem, 4vw, 2.25rem);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    animation: auth-in .4s cubic-bezier(.2, .8, .2, 1) both;
}
.quiz-meta { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; margin-bottom: .75rem; }
.quiz-title { margin: 0 0 .5rem; font-size: clamp(1.3rem, 3.5vw, 1.7rem); }
.quiz-hint { margin: 0 0 1.5rem; color: var(--text-muted); font-size: .92rem; }

.quiz-reveal-btn { width: 100%; justify-content: center; list-style: none; cursor: pointer; }
.quiz-reveal-btn::-webkit-details-marker { display: none; }
.quiz-reveal[open] .quiz-reveal-btn { display: none; }
.quiz-answer { animation: rise .4s cubic-bezier(.2, .8, .2, 1) both; }

.quiz-rate-label { margin: 1.5rem 0 .6rem; font-weight: 600; text-align: center; }
.quiz-rate { display: grid; grid-template-columns: repeat(3, 1fr); gap: .6rem; }
.quiz-rate-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: .4rem;
    min-height: 64px;
    padding: .75rem .5rem;
    font: inherit;
    font-weight: 700;
    font-size: .85rem;
    color: var(--lv);
    background: color-mix(in srgb, var(--lv) 12%, var(--surface));
    border: 1px solid color-mix(in srgb, var(--lv) 35%, transparent);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: transform .15s ease, background .15s ease;
}
.quiz-rate-btn:hover { background: color-mix(in srgb, var(--lv) 20%, var(--surface)); transform: translateY(-2px); }
.quiz-rate-btn:active { transform: scale(.96); }

.quiz-done { width: min(100%, 420px); margin: 2rem auto 0; text-align: center; }
.quiz-done-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: .6rem; margin-top: 1.25rem; }
@media (max-width: 480px) {
    .quiz-rate { grid-template-columns: 1fr; }
    .quiz-rate-btn { flex-direction: row; justify-content: center; min-height: 48px; }
}
@media (prefers-reduced-motion: reduce) { .quiz-card, .quiz-answer { animation: none; } }

.panel-header-actions { display: flex; align-items: center; gap: .4rem; }

/* ===== Tags d'un formulaire : cases à cocher en pastilles (remplace <select multiple>,
   injouable au doigt sur mobile) ===== */
.tag-checks { display: flex; flex-wrap: wrap; gap: .5rem; }
.tag-checks > div { margin: 0; }
.tag-checks label {
    display: inline-flex;
    align-items: center;
    gap: .45rem;
    min-height: 40px;
    padding: .4rem .9rem;
    font-size: .88rem;
    color: var(--text);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 999px;
    cursor: pointer;
    transition: background .15s ease, border-color .15s ease, color .15s ease;
}
.tag-checks label:hover { border-color: var(--primary); }
.tag-checks input[type="checkbox"] { width: 1rem; height: 1rem; margin: 0; accent-color: var(--primary); }
.tag-checks label:has(input:checked) { color: var(--primary); background: var(--primary-soft); border-color: var(--primary); font-weight: 600; }

/* ===== Accueil : mise en page à 3 colonnes (menu | contenu | volet) ===== */
.welcome-layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 1.25rem; align-items: start; }
.welcome-main { min-width: 0; }
.welcome-section-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: .75rem; }
.welcome-section-head h2 { margin: 0; }
.welcome-section-link { display: inline-flex; align-items: center; gap: .3rem; font-size: .85rem; font-weight: 600; color: var(--primary); text-decoration: none; }
.welcome-section-link .icon { width: 14px; height: 14px; }
.welcome-section-link:hover { text-decoration: underline; }
.welcome-twocol { display: grid; grid-template-columns: 1fr 1fr; gap: 1.25rem; }
.welcome-twocol > .welcome-section { min-width: 0; }

/* Carte « objectif actuel », posée sur la bannière */
.welcome-goal-card {
    flex: none;
    display: flex;
    flex-direction: column;
    gap: .4rem;
    width: clamp(180px, 22vw, 220px);
    padding: .9rem 1rem;
    color: #fff;
    text-decoration: none;
    background: rgba(255, 255, 255, .12);
    border: 1px solid rgba(255, 255, 255, .22);
    border-radius: var(--radius-md);
    -webkit-backdrop-filter: blur(6px);
    backdrop-filter: blur(6px);
    transition: background .15s ease, transform .15s ease;
}
.welcome-goal-card:hover { background: rgba(255, 255, 255, .18); transform: translateY(-2px); }
.welcome-goal-label { display: flex; align-items: center; gap: .4rem; font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; opacity: .85; }
.welcome-goal-title { font-weight: 600; font-size: .92rem; line-height: 1.3; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.welcome-goal-card .progress-bar { width: 100%; background: rgba(255, 255, 255, .25); }
.welcome-goal-card .progress-bar span { background: #fff; }
.welcome-goal-pct { font-size: .76rem; opacity: .85; }

/* Rangée de statistiques */
.stat-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: .8rem; }
.stat-card2 {
    display: flex;
    flex-direction: column;
    gap: .3rem;
    padding: 1rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-left: 3px solid var(--cat-color, var(--primary));
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
}
.stat-card2-icon { display: grid; place-items: center; width: 30px; height: 30px; margin-bottom: .1rem; color: var(--cat-color, var(--primary)); background: color-mix(in srgb, var(--cat-color, var(--primary)) 14%, transparent); border-radius: 9px; }
.stat-card2-value { font-size: 1.5rem; font-weight: 700; line-height: 1; letter-spacing: -.01em; }
.stat-card2-label { font-size: .82rem; font-weight: 600; color: var(--text-muted); }
.stat-card2-bar { width: 100%; margin-top: .1rem; }
.stat-card2-sub { font-size: .76rem; color: var(--text-subtle); }

/* Grille des matières */
.subject-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: .8rem; }
.subject-card {
    display: flex;
    flex-direction: column;
    gap: .45rem;
    padding: .9rem 1rem;
    text-decoration: none;
    color: var(--text);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease;
}
.subject-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); border-color: var(--primary); }
.subject-card-name { font-weight: 600; font-size: .92rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.subject-card-pct { align-self: flex-end; font-size: .76rem; font-weight: 600; color: var(--text-muted); font-variant-numeric: tabular-nums; }

/* Dernières activités / prochaines échéances */
.activity-list, .upcoming-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .4rem; }
.activity-list a, .upcoming-list a {
    display: flex;
    align-items: center;
    gap: .7rem;
    min-width: 0;
    padding: .55rem .7rem;
    text-decoration: none;
    color: var(--text);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    transition: border-color .15s ease, transform .15s ease;
    box-sizing: border-box;
}
.activity-list a:hover, .upcoming-list a:hover { border-color: var(--primary); transform: translateX(2px); }
.activity-icon { display: grid; place-items: center; flex: none; width: 30px; height: 30px; color: var(--cat-color, var(--primary)); background: color-mix(in srgb, var(--cat-color, var(--primary)) 14%, transparent); border-radius: 8px; }
.activity-title, .upcoming-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .88rem; }
.activity-time { flex: none; font-size: .74rem; color: var(--text-subtle); }
.upcoming-date {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: none;
    width: 40px;
    height: 40px;
    font-size: .68rem;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--primary);
    background: var(--primary-soft);
    border-radius: 8px;
    line-height: 1.1;
}
.upcoming-date span { font-size: 1rem; }

/* Volet de droite */
.welcome-aside { display: flex; flex-direction: column; gap: .9rem; }
.aside-card { padding: 1rem; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); box-shadow: var(--shadow-sm); }
.aside-card h3 { display: flex; align-items: center; gap: .45rem; margin: 0 0 .7rem; font-size: .88rem; }
.aside-card h3 .icon { color: var(--primary); }
.aside-quote { font-style: italic; color: var(--text-muted); background: linear-gradient(160deg, color-mix(in srgb, var(--primary) 10%, var(--surface)), var(--surface)); }
.aside-quote p { margin: 0 0 .4rem; line-height: 1.5; }
.aside-quote span { display: block; font-style: normal; font-size: .78rem; font-weight: 600; color: var(--primary); }
.aside-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .3rem; }
.aside-list a { display: flex; align-items: center; gap: .6rem; padding: .4rem .3rem; text-decoration: none; color: var(--text); font-size: .86rem; border-radius: var(--radius-sm); transition: background .15s ease; }
.aside-list a:hover { background: var(--surface-hover); }
.aside-list-icon { display: grid; place-items: center; flex: none; width: 26px; height: 26px; color: var(--cat-color, var(--primary)); background: color-mix(in srgb, var(--cat-color, var(--primary)) 14%, transparent); border-radius: 7px; }
.aside-checklist { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .1rem; }
.aside-checklist li { display: flex; align-items: center; gap: .5rem; padding: .2rem 0; font-size: .86rem; }
.aside-checklist form { margin: 0; }
.aside-checklist .is-done { color: var(--text-muted); text-decoration: line-through; }
.aside-date { display: flex; align-items: center; gap: .6rem; font-size: .85rem; color: var(--text-muted); text-transform: capitalize; }
.aside-date .icon { color: var(--primary); }

@media (max-width: 1100px) {
    .welcome-layout { grid-template-columns: 1fr; }
    .welcome-aside { flex-direction: row; flex-wrap: wrap; }
    .aside-card { flex: 1 1 220px; }
}
@media (max-width: 640px) {
    .welcome-twocol { grid-template-columns: 1fr; }
    .stat-row { grid-template-columns: repeat(2, 1fr); }
    .welcome-aside { flex-direction: column; }
    .welcome-hero { flex-wrap: wrap; }
    .welcome-goal-card { width: 100%; }
}
@media (max-width: 420px) {
    .stat-row { grid-template-columns: 1fr 1fr; gap: .6rem; }
    .stat-card2 { padding: .8rem; }
}

/* ===== Leçon du jour (série, XP, questions) ===== */
:root { --flame: #ea580c; --flame-soft: rgba(234, 88, 12, .12); --on-solid: #fff; }
:root[data-theme="dark"] { --flame: #fb923c; --flame-soft: rgba(251, 146, 60, .16); --on-solid: #0b0d14; }
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) { --flame: #fb923c; --flame-soft: rgba(251, 146, 60, .16); --on-solid: #0b0d14; }
}
.btn-lg { padding: .8rem 1.4rem; font-size: 1rem; border-radius: var(--radius-md); }
.nav-link-lesson:not(.active) .icon { color: var(--flame); opacity: 1; }

.streak-flame { display: inline-flex; color: var(--text-subtle); }
.streak-flame .icon { fill: transparent; transition: fill .3s ease, color .3s ease; }
.is-alive .streak-flame, .is-done .streak-flame, .streak-flame.is-lit { color: var(--flame); }
.is-alive .streak-flame .icon, .is-done .streak-flame .icon, .streak-flame.is-lit .icon { fill: color-mix(in srgb, var(--flame) 32%, transparent); }
@keyframes flame-flicker {
    0%, 100% { transform: scale(1) rotate(-1.5deg); }
    50% { transform: scale(1.07) rotate(2deg); }
}

.streak-hero {
    display: flex;
    align-items: center;
    gap: 1.1rem;
    padding: 1.25rem 1.4rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
}
.streak-hero.is-alive, .streak-hero.is-done {
    border-color: color-mix(in srgb, var(--flame) 45%, var(--border));
    background: linear-gradient(135deg, color-mix(in srgb, var(--flame) 13%, var(--surface)), var(--surface) 72%);
}
.streak-flame-big .icon { width: 64px; height: 64px; stroke-width: 1.6; transform-origin: 50% 90%; }
.streak-hero.is-done .streak-flame-big .icon { animation: flame-flicker 1.8s ease-in-out infinite; }
.streak-main { min-width: 0; }
.streak-count { margin: 0; font-size: 1.05rem; font-weight: 600; }
.streak-count span { font-size: 2.2rem; font-weight: 800; line-height: 1; margin-right: .25rem; }
.streak-hero.is-alive .streak-count span, .streak-hero.is-done .streak-count span { color: var(--flame); }
.streak-note { margin: .3rem 0 0; color: var(--text-muted); font-size: .9rem; line-height: 1.45; }

.week-strip { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: .35rem; margin: 1.1rem 0 1.25rem; }
.week-day { display: flex; flex-direction: column; align-items: center; gap: .3rem; font-size: .75rem; color: var(--text-muted); }
.week-day-dot {
    display: grid;
    place-items: center;
    width: 36px;
    height: 36px;
    color: var(--flame);
    border: 2px dashed var(--border);
    border-radius: 50%;
}
.week-day-dot .icon { width: 18px; height: 18px; fill: color-mix(in srgb, var(--flame) 35%, transparent); }
.week-day.is-done .week-day-dot { border-style: solid; border-color: var(--flame); background: var(--flame-soft); }
.week-day.is-today .week-day-dot { border-style: solid; border-color: var(--primary); }
.week-day.is-today.is-done .week-day-dot { border-color: var(--flame); }
.week-day.is-today .week-day-letter { color: var(--text); font-weight: 700; }

.lesson-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .7rem; margin-bottom: 1.25rem; }
.lesson-stats > div {
    display: flex;
    flex-direction: column;
    gap: .15rem;
    padding: .85rem 1rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
}
.lesson-stats b { display: inline-flex; align-items: center; gap: .3rem; font-size: 1.35rem; }
.lesson-stats b .icon { width: 18px; height: 18px; color: var(--flame); }
.lesson-stats span { color: var(--text-muted); font-size: .8rem; }

.lesson-cta {
    padding: 1.25rem 1.4rem;
    text-align: center;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
}
.lesson-cta-title { display: flex; align-items: center; justify-content: center; gap: .5rem; margin: 0 0 1rem; font-weight: 600; }
.lesson-cta-title .icon { color: var(--success); }
.lesson-cta form { margin: 0; }
.lesson-cta-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: .6rem; }
.lesson-cta-hint { margin: .9rem 0 0; }
.lesson-start { width: min(100%, 360px); justify-content: center; background: var(--flame); border-color: var(--flame); color: var(--on-solid); box-shadow: 0 4px 0 color-mix(in srgb, var(--flame) 60%, #000); }
.lesson-start:hover { background: var(--flame); filter: brightness(1.06); }
.lesson-start:active { transform: translateY(2px); box-shadow: 0 2px 0 color-mix(in srgb, var(--flame) 60%, #000); }

/* Jeu : plein écran, sans menu, comme dans Duolingo */
.app-shell.lesson-focus .sidebar,
.app-shell.lesson-focus .topbar,
.app-shell.lesson-focus .bottom-nav,
.app-shell.lesson-focus .fab-sheet,
.app-shell.lesson-focus .fab-backdrop { display: none; }
.app-shell.lesson-focus .page { padding-bottom: 1.5rem; }
.lesson-shell { width: min(100%, 680px); margin: 0 auto; }
.lesson-top { display: flex; align-items: center; gap: .9rem; margin-bottom: 1.4rem; }
.lesson-quit { display: inline-flex; padding: .35rem; color: var(--text-muted); border-radius: var(--radius-sm); }
.lesson-quit:hover { color: var(--danger); background: var(--surface-hover); }
.lesson-bar { flex: 1; height: 14px; overflow: hidden; background: var(--border); border-radius: 999px; }
.lesson-bar > span {
    display: block;
    width: var(--pct, 0%);
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--accent-2));
    border-radius: 999px;
    transition: width .5s cubic-bezier(.2, .8, .2, 1);
}
.lesson-xp { display: inline-flex; align-items: center; gap: .25rem; font-weight: 800; color: var(--flame); }
.lesson-xp .icon { width: 18px; height: 18px; }

.lesson-card { display: flex; flex-direction: column; gap: 1rem; min-height: calc(100vh - 8rem); animation: rise .3s cubic-bezier(.2, .8, .2, 1) both; }
/* La leçon est un <form> : on neutralise les règles génériques « form p / form label / form input ». */
.lesson-card p { display: block; margin: 0; }
.lesson-card .lesson-kind { display: flex; flex-direction: row; align-items: center; gap: .5rem; }
.lesson-prompt { margin: 0; font-size: clamp(1.25rem, 3.6vw, 1.6rem); line-height: 1.3; }
.lesson-context {
    margin: 0;
    padding: .9rem 1.1rem;
    color: var(--text);
    background: var(--surface);
    border: 1px solid var(--border);
    border-left: 4px solid var(--primary);
    border-radius: var(--radius-md);
    line-height: 1.55;
}
.lesson-context.is-code {
    max-height: 9rem;
    overflow: auto;
    white-space: pre-wrap;
    word-break: break-word;
    font-family: ui-monospace, "SF Mono", Consolas, monospace;
    font-size: .86rem;
    border-left-color: var(--danger);
}
.lesson-options { display: grid; gap: .7rem; }
.lesson-option { position: relative; }
.lesson-card .lesson-option input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.lesson-option-label {
    display: flex;
    align-items: center;
    gap: .85rem;
    padding: .85rem 1rem;
    background: var(--surface);
    border: 2px solid var(--border);
    border-bottom-width: 4px;
    border-radius: var(--radius-md);
    color: var(--text);
    font-size: 1rem;
    font-weight: 500;
    line-height: 1.4;
    cursor: pointer;
    transition: border-color .15s ease, background .15s ease, transform .1s ease;
}
.lesson-option-num {
    display: grid;
    place-items: center;
    flex: none;
    width: 28px;
    height: 28px;
    color: var(--text-muted);
    font-size: .78rem;
    font-weight: 700;
    border: 2px solid var(--border);
    border-radius: 8px;
}
.lesson-option-num .icon { width: 16px; height: 16px; }
.lesson-option:hover .lesson-option-label { background: var(--surface-hover); }
.lesson-option input:checked + .lesson-option-label { background: var(--primary-soft); border-color: var(--primary); }
.lesson-option input:checked + .lesson-option-label .lesson-option-num { color: var(--on-primary); background: var(--primary); border-color: var(--primary); }
.lesson-option input:focus-visible + .lesson-option-label { outline: 3px solid color-mix(in srgb, var(--primary) 45%, transparent); outline-offset: 2px; }
.lesson-option:active .lesson-option-label { transform: translateY(2px); border-bottom-width: 2px; }
.lesson-option.is-correct .lesson-option-label { background: var(--success-soft); border-color: var(--success); }
.lesson-option.is-correct .lesson-option-num { color: var(--on-solid); background: var(--success); border-color: var(--success); }
.lesson-option.is-wrong .lesson-option-label { background: var(--danger-soft); border-color: var(--danger); }
.lesson-option.is-wrong .lesson-option-num { color: var(--on-solid); background: var(--danger); border-color: var(--danger); }
.lesson-check { width: 100%; justify-content: center; margin-top: auto; }
.lesson-check:disabled { cursor: not-allowed; color: var(--text-subtle); background: var(--border); border-color: var(--border); box-shadow: none; }

.lesson-reveal-btn { width: 100%; justify-content: center; list-style: none; cursor: pointer; }
.lesson-reveal-btn::-webkit-details-marker { display: none; }
.lesson-reveal[open] .lesson-reveal-btn { display: none; }
.lesson-recall-answer { padding: .9rem 1.1rem; line-height: 1.55; background: var(--surface); border: 1px dashed var(--border); border-radius: var(--radius-md); }
.lesson-recall-ask { margin: 1rem 0 .6rem; font-weight: 600; text-align: center; }
.lesson-recall-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; }
.lesson-recall-buttons .btn { justify-content: center; }

.lesson-feedback {
    position: sticky;
    bottom: 0;
    z-index: 5;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: .8rem 1.2rem;
    margin: auto -.4rem 0;
    padding: 1rem 1.2rem calc(1rem + env(safe-area-inset-bottom, 0px));
    border: 1px solid;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    animation: rise .3s cubic-bezier(.2, .8, .2, 1) both;
}
.lesson-feedback.is-ok { background: color-mix(in srgb, var(--success) 12%, var(--surface)); border-color: var(--success); }
.lesson-feedback.is-bad { background: color-mix(in srgb, var(--danger) 11%, var(--surface)); border-color: var(--danger); }
.lesson-feedback-body { flex: 1 1 240px; min-width: 0; }
.lesson-feedback-title { display: flex; align-items: center; gap: .45rem; font-size: 1.05rem; }
.lesson-feedback.is-ok .lesson-feedback-title { color: var(--success); }
.lesson-feedback.is-bad .lesson-feedback-title { color: var(--danger); }
.lesson-explain { margin: .35rem 0 0; color: var(--text); font-size: .92rem; line-height: 1.5; }
.lesson-review-link { display: inline-flex; align-items: center; gap: .3rem; margin-top: .4rem; color: var(--text-muted); font-size: .82rem; }
.lesson-review-link:hover { color: var(--primary); }
.lesson-next { flex: 0 1 200px; justify-content: center; }
.lesson-feedback.is-ok .lesson-next { background: var(--success); border-color: var(--success); color: var(--on-solid); }
.lesson-feedback.is-bad .lesson-next { background: var(--danger); border-color: var(--danger); color: var(--on-solid); }
@media (max-width: 520px) { .lesson-next { flex: 1 1 100%; } }

.lesson-result { width: min(100%, 520px); margin: 1rem auto 0; text-align: center; }
.result-flame .icon { width: 96px; height: 96px; stroke-width: 1.5; transform-origin: 50% 90%; }
.result-flame.is-lit .icon { animation: flame-flicker 1.6s ease-in-out infinite, splash-pop .7s cubic-bezier(.34, 1.56, .64, 1) both; }
.result-title { margin: .4rem 0 .2rem; font-size: 1.7rem; }
.result-streak { margin: 0 0 .5rem; font-size: 1.05rem; font-weight: 600; }
.result-streak span { font-size: 1.9rem; font-weight: 800; color: var(--flame); margin-right: .2rem; }
.result-streak-muted { color: var(--text-muted); font-size: .9rem; font-weight: 400; }
.result-cards { display: grid; grid-template-columns: 1fr 1fr; gap: .8rem; margin: 1.25rem 0; }
.result-card { display: flex; flex-direction: column; gap: .25rem; padding: 1rem; background: var(--surface); border: 2px solid var(--border); border-radius: var(--radius-md); }
.result-card span { color: var(--text-muted); font-size: .78rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }
.result-card b { display: inline-flex; align-items: center; justify-content: center; gap: .3rem; font-size: 1.5rem; }
.result-card.is-xp { border-color: var(--flame); }
.result-card.is-xp b { color: var(--flame); }
.result-card.is-acc { border-color: var(--primary); }
.result-card.is-acc b { color: var(--primary); }
.result-mistakes { margin: 1rem 0; text-align: left; }
.result-mistakes h2 { font-size: 1rem; margin: 0 0 .6rem; }
.lesson-result .quiz-done-actions form { margin: 0; }

.aside-streak { display: flex; align-items: center; gap: .8rem; text-decoration: none; color: inherit; }
.aside-streak:hover { border-color: var(--flame); }
.aside-streak .streak-flame .icon { width: 34px; height: 34px; }
.aside-streak-text { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.aside-streak-text strong { font-size: .95rem; }
.aside-streak-text span { color: var(--text-muted); font-size: .8rem; }
.aside-streak.is-alive, .aside-streak.is-done { border-color: color-mix(in srgb, var(--flame) 45%, var(--border)); background: linear-gradient(135deg, color-mix(in srgb, var(--flame) 12%, var(--surface)), var(--surface) 75%); }
.aside-streak > .icon { color: var(--text-subtle); }

@media (max-width: 520px) {
    .streak-hero { padding: 1rem; gap: .8rem; }
    .streak-flame-big .icon { width: 52px; height: 52px; }
    .lesson-stats { gap: .5rem; }
    .lesson-stats > div { padding: .7rem .75rem; }
    .lesson-stats b { font-size: 1.1rem; }
}
@media (prefers-reduced-motion: reduce) {
    .streak-hero.is-done .streak-flame-big .icon, .result-flame.is-lit .icon, .lesson-card, .lesson-feedback { animation: none; }
    .lesson-bar > span { transition: none; }
}
.aside-card.welcome-streak { padding: .85rem 1.1rem; margin: 1rem 0 1.25rem; }
.welcome-streak .streak-flame .icon { width: 30px; height: 30px; }
.card > .icon.about-flame:first-child { color: var(--flame); }
/* Page À propos : l'icône reste à gauche du texte, même quand celui-ci passe sur plusieurs lignes. */
.about-list .card { flex-wrap: nowrap; align-items: flex-start; }
.about-list .card > .icon { margin-top: .2rem; }
.about-list .card > div { flex: 1 1 0; min-width: 0; }

/* ===== Télécharger l'application ===== */
.dl-notice { margin-bottom: 1rem; }
.dl-grid { margin-top: 1rem; }
.dl-card { display: flex; flex-direction: column; gap: .6rem; }
.dl-card .panel-header { margin-bottom: 0; }
.dl-card.is-recommended { order: -1; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft), var(--shadow-sm); }
.dl-title { display: flex; align-items: center; gap: .5rem; font-size: 1.1rem; }
.dl-title .icon { color: var(--primary); }
.dl-files { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .75rem; }
.dl-btn { width: 100%; justify-content: center; }
.dl-btn[hidden] { display: none; }
.dl-size { font-weight: 400; opacity: .85; }
.dl-note { margin: .35rem 0 0; font-size: .85rem; line-height: 1.45; }
.dl-help { margin: auto 0 0; padding-top: .6rem; border-top: 1px solid var(--border); line-height: 1.45; }
.dl-steps { margin: 0; padding-left: 1.2rem; font-size: .88rem; line-height: 1.55; color: var(--text); }
.dl-steps li + li { margin-top: .25rem; }
.dl-footer { margin-top: 1.25rem; }
