/* Bâtons — feuille de style unique.
   Mobile d'abord, clair/sombre automatique, contrastes WCAG AA, cibles tactiles ≥ 44 px. */

:root {
    --bg: #f7f4ee;
    --surface: #fffdf9;
    --ink: #1c1917;
    --muted: #6b645e;          /* ≥ 5:1 sur les fonds clairs */
    --line: #e7e1d6;           /* séparateurs décoratifs */
    --field: #8a837c;          /* bordure des champs : ≥ 3:1 */
    --accent: #c2410c;
    --accent-bg: #c2410c;      /* fond des aplats avec texte blanc : ≥ 4.5:1 */
    --danger: #b91c1c;
    --focus: #1d4ed8;
    --radius: 14px;
    --tap: 2.75rem;            /* 44 px */
    --shadow: 0 1px 2px rgb(28 25 23 / .06), 0 2px 8px rgb(28 25 23 / .05);
    color-scheme: light dark;
}
/* Thème forcé (Apparence) : html[data-theme=light|dark] ; sans attribut, on suit l'appareil. */
html[data-theme=light] { color-scheme: light; }
html[data-theme=dark] { color-scheme: dark; }
@media (prefers-color-scheme: dark) {
    html:not([data-theme=light]) {
        --bg: #161412;
        --surface: #211e1b;
        --ink: #f1ede6;
        --muted: #a8a29e;
        --line: #36312c;
        --field: #78716c;
        --accent: #fb923c;
        --danger: #f87171;
        --focus: #93c5fd;
        --shadow: none;
    }
}
html[data-theme=dark] {
        --bg: #161412;
        --surface: #211e1b;
        --ink: #f1ede6;
        --muted: #a8a29e;
        --line: #36312c;
        --field: #78716c;
        --accent: #fb923c;
        --danger: #f87171;
        --focus: #93c5fd;
        --shadow: none;
    }

/* Couleur d'une catégorie employée comme TEXTE : éclaircie en mode sombre pour rester lisible. */
[style*="--c"] { --c-ink: var(--c-ink-l, var(--c)); }   /* --c-ink-l : version assez foncée, calculée en PHP (cvars) */
@media (prefers-color-scheme: dark) { html:not([data-theme=light]) [style*="--c"] { --c-ink: color-mix(in srgb, var(--c) 55%, white); } }
html[data-theme=dark] [style*="--c"] { --c-ink: color-mix(in srgb, var(--c) 55%, white); }

* { box-sizing: border-box; }
[hidden] { display: none !important; }   /* l'attribut hidden l'emporte toujours sur les display des classes */
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
    margin: 0;
    font: 1rem/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    background: var(--bg);
    color: var(--ink);
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    overflow-wrap: break-word;
}
main {
    width: 100%; max-width: 860px; margin: 0 auto; flex: 1;
    padding: 1rem max(1rem, env(safe-area-inset-right)) max(2.5rem, env(safe-area-inset-bottom)) max(1rem, env(safe-area-inset-left));
}
main:focus { outline: none; }
a { color: inherit; }
h1 { font-size: 1.5rem; margin: 0; letter-spacing: -.01em; line-height: 1.2; }
h2 { font-size: 1.1rem; margin: 1.6rem 0 .6rem; }
.muted { color: var(--muted); font-weight: normal; }
.center { text-align: center; }
.grow { flex: 1; min-width: 0; }
.small { font-size: .85rem; margin: 0; }
code { font-size: .85em; background: var(--line); padding: .05rem .3rem; border-radius: 4px; }

/* Masqué visuellement, lu par les lecteurs d'écran. */
.sr {
    position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* Focus clavier bien visible partout. */
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 4px; }

/* Lien d'évitement. */
.skip {
    position: absolute; left: .5rem; top: -4rem; z-index: 100;
    background: var(--surface); color: var(--ink); padding: .7rem 1rem; border-radius: 10px;
    font-weight: 600; box-shadow: var(--shadow);
}
.skip:focus { top: .5rem; }

/* Icônes d'interface (SVG). */
svg.ui { width: 1.35rem; height: 1.35rem; fill: currentColor; flex: none; }

/* --- Barre du haut ------------------------------------------------------- */
.topbar {
    display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: .25rem 1rem;
    padding: .45rem max(1rem, env(safe-area-inset-right)) .45rem max(1rem, env(safe-area-inset-left));
    padding-top: max(.45rem, env(safe-area-inset-top));
    background: var(--surface); color: var(--ink);
    border-bottom: 1px solid color-mix(in srgb, var(--ink) 28%, var(--bg));   /* même filet que la barre d'onglets */
}
.brand { display: flex; align-items: center; gap: .5rem; min-height: var(--tap); text-decoration: none; font-weight: 700; font-size: 1.1rem; }
.brand svg { width: 28px; height: 28px; }
.brand .slash { color: var(--accent); }
.topbar > nav { display: flex; gap: .25rem; }
.topbar > nav a {
    display: inline-flex; align-items: center; gap: .45rem; min-height: var(--tap);
    text-decoration: none; padding: 0 .9rem 0 .75rem; border-radius: 999px; font-size: .95rem; font-weight: 600; color: var(--muted);
}
.topbar > nav a svg.ui { width: 1.25rem; height: 1.25rem; }
.topbar > nav a:hover { color: var(--ink); background: var(--bg); }
.topbar > nav a[aria-current] { background: color-mix(in srgb, var(--accent) 18%, var(--surface)); color: var(--ink); }
.topbar > nav a[aria-current] svg.ui { color: var(--accent); }


/* --- Menu du logo (details/summary : fonctionne sans JS) -------------------- */
.appmenu { position: relative; }
.appmenu > summary { list-style: none; cursor: pointer; padding: 0 .4rem 0 .2rem; margin-left: -.2rem; border-radius: 10px; }
.appmenu > summary::-webkit-details-marker { display: none; }
.appmenu > summary:hover { background: var(--bg); }
.appmenu .caret { width: 1.1rem; height: 1.1rem; opacity: .75; transition: transform .15s; }
.appmenu[open] .caret { transform: rotate(180deg); }
.appmenu-panel {
    position: absolute; z-index: 20; top: calc(100% + .35rem); left: 0; min-width: 16.5rem;
    background: var(--surface); color: var(--ink); border: 1px solid var(--line); border-radius: 12px;
    box-shadow: 0 8px 28px rgb(0 0 0 / .22); padding: .35rem;
}
.appmenu-panel ul { list-style: none; margin: 0; padding: 0; }
.appmenu-panel a {
    display: flex; align-items: center; min-height: var(--tap); padding: 0 .8rem; border-radius: 8px;
    text-decoration: none; font-weight: 500;
}
.appmenu-panel a:hover { background: var(--bg); }
.appmenu-panel a[aria-current] { font-weight: 700; background: var(--bg); }
.appmenu-panel :focus-visible { outline-color: var(--focus); }
.appmenu-version { margin: .3rem .8rem .2rem; padding-top: .4rem; border-top: 1px solid var(--line); font-size: .85rem; color: var(--muted); }

/* --- Éléments masqués ---------------------------------------------------------- */
.appmenu-private { list-style: none; margin: .3rem 0 0; padding: .3rem 0 0; border-top: 1px solid var(--line); }
.appmenu-panel a svg.ui, .menu-btn svg.ui { width: 1.2rem; height: 1.2rem; margin-right: .5rem; color: var(--muted); }
.appmenu-private form { margin: 0; }
.menu-btn {
    display: flex; align-items: center; width: 100%; min-height: var(--tap); padding: 0 .8rem; border-radius: 8px;
    background: none; border: 0; color: inherit; font: inherit; font-weight: 500; text-align: left; cursor: pointer;
}
.menu-btn:hover { background: var(--bg); }
.lock-quick { margin: 0 0 0 auto; }
.topbar .lock-quick .icon-btn { color: var(--accent); }
.hidden-mark { display: inline-flex; vertical-align: middle; color: var(--muted); }
.hidden-mark svg.ui { width: 1rem; height: 1rem; }
.badge svg.ui { width: .95rem; height: .95rem; vertical-align: -2px; }
.icon-btn.is-hidden { color: var(--accent); }
.check { display: flex; align-items: center; gap: .6rem; min-height: var(--tap); }
.check input { width: 1.4rem; height: 1.4rem; margin: 0; accent-color: var(--accent-bg); flex: none; }
.check label { margin: 0; display: inline-flex; align-items: center; gap: .35rem; flex: none; }
.check label svg.ui { width: 1.15rem; height: 1.15rem; color: var(--muted); }
.field-help { margin: 0 0 1rem; }
.narrow-card { max-width: 28rem; margin-left: auto; margin-right: auto; }
.unlock-card { text-align: center; }
.unlock-card label { text-align: left; }
.unlock-icon { display: inline-grid; place-items: center; width: 3.5rem; height: 3.5rem; border-radius: 50%; background: var(--bg); color: var(--muted); margin-bottom: .5rem; }
.unlock-icon svg.ui { width: 1.8rem; height: 1.8rem; }
.pin-input { letter-spacing: .4em; font-variant-numeric: tabular-nums; }
.btn.wide { width: 100%; }
.btn svg.ui { width: 1.15rem; height: 1.15rem; }
.or { display: flex; align-items: center; gap: .7rem; color: var(--muted); margin: 1rem 0; }
.or::before, .or::after { content: ""; flex: 1; border-top: 1px solid var(--line); }
.help-list { padding-left: 1.2rem; }
input[type=password] {
    font: inherit; font-size: max(1rem, 16px); font-weight: normal; min-height: var(--tap); padding: .5rem .7rem; border-radius: 9px;
    border: 1px solid var(--field); background: var(--bg); color: var(--ink); width: 100%; max-width: 100%;
}

/* --- Réorganisation ------------------------------------------------------------ */
.order-group { margin-bottom: 1.4rem; }
.order-group-head { display: flex; align-items: center; justify-content: space-between; gap: .5rem; margin-bottom: .4rem; }
.order-group-head h2 { margin: 0; font-size: 1rem; }
.order-buttons { display: flex; flex: none; }
.icon-btn:disabled { opacity: .3; cursor: default; background: none; }

/* --- Messages flash ------------------------------------------------------ */
.flash {
    position: sticky; top: 0; z-index: 10;
    display: flex; gap: .5rem 1rem; align-items: center; justify-content: center; flex-wrap: wrap;
    padding: .3rem 3rem .3rem 1rem; min-height: var(--tap);
    background: var(--accent-bg); color: #fff; font-weight: 500;
    animation: flash-in .25s ease-out;
}
.flash form { margin: 0; }
.flash-btn {
    min-height: 2.25rem; padding: 0 .9rem; border-radius: 8px; cursor: pointer;
    font: inherit; font-weight: 700; color: #fff; background: rgb(0 0 0 / .18); border: 1px solid rgb(255 255 255 / .6);
}
.flash-close {
    position: absolute; right: .2rem; top: 50%; transform: translateY(-50%);
    width: var(--tap); height: var(--tap); display: grid; place-items: center;
    background: none; border: 0; color: #fff; cursor: pointer; border-radius: 8px;
}
.flash :focus-visible { outline-color: #fff; }
@keyframes flash-in { from { transform: translateY(-100%); } }

/* --- Boutons ------------------------------------------------------------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: .3rem;
    min-height: var(--tap); padding: .45rem 1rem; border-radius: 10px; border: 1px solid transparent;
    background: var(--ink); color: var(--bg);
    font: inherit; font-weight: 600; text-decoration: none; cursor: pointer; text-align: center;
}
.btn.accent { background: var(--c-solid, color-mix(in srgb, var(--accent-bg) 88%, black)); color: var(--c-on, #fff); }
.btn.ghost { background: transparent; color: var(--ink); border-color: var(--field); }
.btn.danger { background: transparent; color: var(--danger); border-color: currentColor; }
.icon-btn {
    display: inline-grid; place-items: center; width: var(--tap); height: var(--tap);
    border-radius: 10px; border: 0; background: none; color: var(--muted); cursor: pointer; padding: 0;
}
.icon-btn:hover { background: var(--bg); color: var(--ink); }
.icon-btn.danger:hover { color: var(--danger); }

.page-head { display: flex; align-items: center; justify-content: space-between; gap: .75rem 1rem; flex-wrap: wrap; margin: .5rem 0 1rem; }
.actions { display: flex; gap: .5rem; flex-wrap: wrap; }

/* --- Grille des catégories ------------------------------------------------ */
h2.group { font-size: .8125rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 1.4rem 0 .5rem; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(150px, 100%), 1fr)); gap: .7rem; }
.tile {
    position: relative; background: var(--surface); border-radius: var(--radius);
    box-shadow: var(--shadow); border: 1px solid var(--line); overflow: hidden;
}
.tile::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 5px; background: var(--c); }
.tile form { margin: 0; height: 100%; }
.tap {
    display: flex; flex-direction: column; align-items: flex-start; gap: .2rem;
    width: 100%; height: 100%; min-height: 118px; padding: .9rem 2.6rem .8rem 1.1rem;
    background: none; border: 0; color: inherit; font: inherit; text-align: left; cursor: pointer;
    transition: background .15s;
}
.tap:hover { background: color-mix(in srgb, var(--c) 6%, transparent); }
.tap:active { background: color-mix(in srgb, var(--c) 16%, transparent); }
.tap:focus-visible { outline-offset: -3px; border-radius: var(--radius); }
.tap .name { font-weight: 650; line-height: 1.2; }
.tap .meta { font-size: .85rem; color: var(--muted); margin-top: auto; }
.tap .meta b { color: var(--c-ink); font-size: 1rem; }
.more {
    position: absolute; top: 0; right: 0; width: var(--tap); height: var(--tap);
    display: grid; place-items: center; text-decoration: none; color: var(--muted); border-radius: 0 var(--radius) 0 10px;
}
.more:hover { color: var(--ink); background: var(--bg); }

.icon {
    display: inline-grid; place-items: center; width: 2.1rem; height: 2.1rem; border-radius: 10px; flex: none;
    background: color-mix(in srgb, var(--c) 15%, transparent); color: var(--c-ink);
    font-size: 1.15rem; font-weight: 700; line-height: 1;
}
.icon svg { width: 62%; height: 62%; fill: currentColor; }
.icon.big { width: 3.2rem; height: 3.2rem; font-size: 1.7rem; border-radius: 14px; }
.icon.sm { width: 1.6rem; height: 1.6rem; font-size: .9rem; border-radius: 7px; vertical-align: middle; margin-right: .35rem; }

.empty { text-align: center; padding: 2.5rem 1rem; max-width: 30rem; margin: 0 auto; }
.tally-big { width: 72px; height: 72px; color: var(--accent); }

/* --- Fiche catégorie ------------------------------------------------------ */
.cat-title { display: flex; align-items: center; gap: .8rem; min-width: 0; }
.cat-title p { margin: .1rem 0 0; }
.badge { display: inline-block; font-size: .8125rem; padding: .1rem .5rem; border-radius: 999px; background: var(--line); }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; box-shadow: var(--shadow); margin-bottom: 1rem; }

/* --- Formulaires ---------------------------------------------------------- */
label { display: block; font-size: .9rem; font-weight: 600; margin-bottom: .8rem; flex: 1; min-width: 0; }
label > input, label > .error { display: block; margin-top: .3rem; }
input[type=text], input[type=search], input[type=datetime-local] {
    font: inherit; font-size: max(1rem, 16px); /* ≥ 16 px : pas de zoom automatique sur iOS */
    font-weight: normal; min-height: var(--tap); padding: .5rem .7rem; border-radius: 9px;
    border: 1px solid var(--field); background: var(--bg); color: var(--ink); width: 100%; max-width: 100%;
}
input[aria-invalid="true"] { border-color: var(--danger); border-width: 2px; }
input[type=datetime-local] { -webkit-appearance: none; appearance: none; }
input[type=file] { font: inherit; font-weight: normal; display: block; margin-top: .4rem; max-width: 100%; min-height: var(--tap); padding: .4rem 0; }
.row { display: flex; gap: 0 .8rem; flex-wrap: wrap; }
.row > label { flex: 1 1 12rem; }
.row > .narrow { flex: 0 1 9rem; }
.error { color: var(--danger); font-weight: 600; }
.form-actions { display: flex; gap: .5rem; flex-wrap: wrap; }
fieldset { border: 0; padding: 0; margin: 0 0 .8rem; min-width: 0; }
legend { font-size: .9rem; font-weight: 600; margin-bottom: .4rem; padding: 0; }

.swatches { display: flex; flex-wrap: wrap; gap: .1rem .2rem; }
.swatch-row-label { flex: 0 0 100%; margin: .5rem 0 0; font-size: .875rem; color: var(--muted); font-weight: 600; }
.swatch { margin: 0; flex: 0 0 auto; cursor: pointer; position: relative; display: grid; place-items: center; width: var(--tap); height: var(--tap); }
.swatch input[type=radio] { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.swatch span { display: block; width: 2rem; height: 2rem; border-radius: 50%; background: var(--c); border: 3px solid var(--surface); box-shadow: 0 0 0 1px var(--field); }
.swatch input:checked + span { box-shadow: 0 0 0 3px var(--ink); }
.swatch input:checked + span::after { content: "✓"; display: grid; place-items: center; height: 100%; color: var(--c-on, #fff); font-weight: 700; font-size: .9rem; }
.swatch input:focus-visible + span { outline: 3px solid var(--focus); outline-offset: 3px; }
.swatch.custom input { width: 2rem; height: 2rem; padding: 0; border: 1px solid var(--field); border-radius: 50%; background: none; cursor: pointer; }

.icon-field { display: flex; align-items: center; gap: .8rem; }
.icon-picker { border: 1px solid var(--line); border-radius: 12px; padding: .7rem; margin-bottom: 1rem; background: var(--bg); }
.icon-picker input[type=search] { background: var(--surface); }
.icon-results { display: grid; grid-template-columns: repeat(auto-fill, minmax(var(--tap), 1fr)); gap: .3rem; margin: .6rem 0 .3rem; max-height: 15rem; overflow-y: auto; }
.icon-choice {
    display: grid; place-items: center; min-height: var(--tap); border: 2px solid transparent; border-radius: 9px;
    background: var(--surface); color: var(--ink); cursor: pointer; padding: 0;
}
.icon-choice svg { width: 1.4rem; height: 1.4rem; fill: currentColor; }
.icon-choice:hover { border-color: var(--line); }
.icon-choice.selected { border-color: var(--c-ink, var(--accent)); color: var(--c-ink, var(--accent)); background: color-mix(in srgb, var(--c, var(--accent)) 12%, transparent); }

/* --- Statistiques et graphique -------------------------------------------- */
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(130px, 100%), 1fr)); gap: .6rem; margin-bottom: 1rem; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: .7rem .8rem; display: flex; flex-direction: column; min-width: 0; }
.stat.wide { grid-column: 1 / -1; }
.stat .k { font-size: .8125rem; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.stat .v { font-size: 1.35rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat .s { font-size: .9rem; color: var(--muted); }

.chart-head { display: flex; justify-content: space-between; gap: .5rem; flex-wrap: wrap; margin-bottom: .6rem; }
.seg { display: inline-flex; flex-wrap: wrap; background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 2px; max-width: 100%; }
.seg a { display: inline-flex; align-items: center; min-height: 2.5rem; text-decoration: none; font-size: .9rem; padding: 0 .7rem; border-radius: 8px; color: var(--muted); }
.seg a[aria-current] { background: var(--surface); color: var(--ink); font-weight: 600; box-shadow: var(--shadow); outline: 1px solid var(--line); }
.chart { width: 100%; height: auto; display: block; }
.chart-axis { stroke: var(--field); stroke-width: 1; }
.chart-empty { fill: var(--line); }
.chart-label, .chart-value, .chart-max { fill: var(--muted); font-size: 12px; text-anchor: middle; font-family: inherit; }
.chart-value { fill: var(--ink); font-weight: 600; }
.chart-max { text-anchor: start; }

/* --- Listes de bâtons ----------------------------------------------------- */
.day { font-size: .9rem; color: var(--muted); font-weight: 600; margin: 1.2rem 0 .4rem; }
.day::first-letter { text-transform: uppercase; }
.events { list-style: none; margin: 0; padding: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.events li { display: flex; align-items: center; gap: .6rem; padding: .25rem .25rem .25rem .8rem; border-top: 1px solid var(--line); border-left: 4px solid var(--c); min-height: 3.2rem; }
.events li:first-child { border-top: 0; }
.events .time { font-variant-numeric: tabular-nums; font-weight: 600; flex: none; }
.events .body { flex: 1; display: flex; flex-wrap: wrap; gap: .1rem .6rem; align-items: baseline; min-width: 0; }
.events .cat { text-decoration: none; font-weight: 600; display: inline-flex; align-items: center; min-height: 2rem; }
.events .cat:hover { text-decoration: underline; }
.events .value { font-weight: 700; color: var(--c-ink); }
.events .note { color: var(--muted); overflow-wrap: anywhere; }
.row-actions { display: flex; flex: none; }
.row-actions form { margin: 0; }
.pager { display: flex; justify-content: space-between; gap: .5rem; margin-top: 1rem; flex-wrap: wrap; }

.order-list { list-style: none; padding: 0; margin: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.order-list li { display: flex; align-items: center; gap: .5rem; padding: .3rem .4rem .3rem .8rem; border-top: 1px solid var(--line); min-height: 3.2rem; }
.order-list li:first-child { border-top: 0; }
.order-list form { margin: 0; }
.order-list a.grow { display: inline-flex; align-items: center; min-height: var(--tap); }

.danger-zone { display: flex; gap: .5rem; flex-wrap: wrap; margin-top: 1.5rem; padding-top: 1rem; border-top: 1px dashed var(--field); }
.danger-zone form { margin: 0; }

/* --- Import ------------------------------------------------------------------ */
.report ul { padding-left: 1.2rem; }
.report details { margin: .5rem 0 1rem; }
.report summary { cursor: pointer; min-height: var(--tap); display: flex; align-items: center; }
.report .errors { color: var(--muted); font-size: .9rem; }
.help { color: var(--muted); }
.help h2 { color: var(--ink); font-size: 1rem; }

/* --- Tactile : pas de sélection de texte ni de menu contextuel sur un appui long --- */
.tile, .tap, .more, .btn, .icon-btn, .seg a, .icon-choice, .swatch, .topbar > nav a {
    -webkit-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

/* --- Petits écrans --------------------------------------------------------- */
@media (max-width: 480px) {
    .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .55rem; }
    h1 { font-size: 1.3rem; }
    .tap { min-height: 110px; padding-left: .95rem; }
    .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .stat .v { font-size: 1.2rem; }
}
@media (max-width: 429px) {
    .brand span { display: none; }       /* petits écrans : logo + flèche seuls (nom lu via aria-label) */
}
@media (max-width: 359px) {
    .topbar > nav a { padding: 0 .55rem; font-size: .9rem; }
    .grid { grid-template-columns: minmax(0, 1fr); }
}

/* --- Grand écran ------------------------------------------------------------ */
@media (min-width: 900px) {
    main { padding-top: 1.5rem; }
    h1 { font-size: 1.7rem; }
}

/* --- Préférences d'accessibilité -------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
@media (forced-colors: active) {
    .tile::before, .events li { forced-color-adjust: none; }
    .icon-btn, .swatch span { border: 1px solid ButtonText; }
}
.card > h2:first-child { margin-top: 0; }
[data-passkey-register] { margin-top: 1rem; }
.narrow-card form + p { margin-top: 1rem; }
.page-head.end { justify-content: flex-end; margin-top: 0; }
main > h1.sr + .day { margin-top: .2rem; }

/* --- Calendrier (grille semaines × jours) ------------------------------------- */
.card-title { margin: 0 0 .6rem; font-size: 1rem; display: flex; flex-wrap: wrap; align-items: baseline; gap: .2rem .6rem; }
.cal-scroll { overflow-x: auto; overscroll-behavior-x: contain; padding-bottom: .3rem; border-radius: 6px; }
.cal { display: block; }
.cal-wrap { display: flex; gap: 6px; align-items: flex-start; }
.cal-days { flex: none; }
.cal-scroll { flex: 1; min-width: 0; }
.cal-label { fill: var(--muted); font-size: 11px; font-family: inherit; }
.cal-0 { fill: var(--line); background: var(--line); }
/* Niveaux du calendrier : 1er niveau déjà bien visible ; en sombre, la couleur est éclaircie (pas noyée dans le fond). */
.cal-wrap, .cal-legend { --c-cal: var(--c); }
@media (prefers-color-scheme: dark) { html:not([data-theme=light]) .cal-wrap, html:not([data-theme=light]) .cal-legend { --c-cal: color-mix(in srgb, var(--c) 70%, white); } }
html[data-theme=dark] .cal-wrap, html[data-theme=dark] .cal-legend { --c-cal: color-mix(in srgb, var(--c) 70%, white); }
.cal-1 { fill: color-mix(in srgb, var(--c-cal) 62%, var(--surface)); background: color-mix(in srgb, var(--c-cal) 62%, var(--surface)); }
.cal-2 { fill: color-mix(in srgb, var(--c-cal) 76%, var(--surface)); background: color-mix(in srgb, var(--c-cal) 76%, var(--surface)); }
.cal-3 { fill: color-mix(in srgb, var(--c-cal) 88%, var(--surface)); background: color-mix(in srgb, var(--c-cal) 88%, var(--surface)); }
.cal-4 { fill: var(--c-cal); background: var(--c-cal); }
.cal-today { stroke: var(--ink); stroke-width: 1.5; }
.cal-legend { display: flex; align-items: center; justify-content: flex-end; gap: 3px; font-size: .8125rem; color: var(--muted); margin-top: .3rem; }
.cal-legend i { display: inline-block; width: 11px; height: 11px; border-radius: 2.5px; }
.cal-legend span { margin: 0 .5rem 0 .15rem; }
@media (forced-colors: active) { .cal rect { forced-color-adjust: none; } }

/* --- Œuvres ------------------------------------------------------------------------- */
input[type=number] {
    font: inherit; font-size: max(1rem, 16px); font-weight: normal; min-height: var(--tap); padding: .5rem .7rem; border-radius: 9px;
    border: 1px solid var(--field); background: var(--bg); color: var(--ink); width: 100%; max-width: 100%;
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: .5rem; margin-bottom: .6rem; flex-wrap: wrap; }
.card-head .card-title { margin: 0; }
.poster {
    flex: none; display: grid; place-items: center; overflow: hidden; border-radius: 6px;
    background: color-mix(in srgb, var(--c, var(--accent)) 14%, var(--bg)); color: var(--c-ink, var(--muted)); font-size: 1.2rem;
}
.poster img { width: 100%; height: 100%; object-fit: cover; display: block; }
.poster svg { width: 55%; height: 55%; fill: currentColor; }
.poster.sm { width: 46px; height: 69px; }
.poster.md { width: 80px; height: 120px; border-radius: 8px; }
.work-list, .work-results { list-style: none; margin: 0; padding: 0; }
.work-list li { display: flex; align-items: center; gap: .7rem; padding: .5rem 0; border-top: 1px solid var(--line); }
.work-list li:first-child { border-top: 0; }
.work-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: .1rem; }
.work-text strong { overflow-wrap: anywhere; line-height: 1.25; }
.work-list form { margin: 0; }
.next-btn { white-space: nowrap; font-variant-numeric: tabular-nums; padding: .45rem .8rem; }
.work-results li { border-top: 1px solid var(--line); }
.work-results li:first-child { border-top: 0; }
.work-results form { margin: 0; }
.work-pick {
    display: flex; align-items: center; gap: .7rem; width: 100%; padding: .45rem .3rem; min-height: var(--tap);
    background: none; border: 0; color: inherit; font: inherit; text-align: left; cursor: pointer; border-radius: 8px;
}
.work-pick:hover { background: var(--bg); }
.search-row { display: flex; gap: .5rem; margin-top: .3rem; }
.search-row input { flex: 1; min-width: 0; }
form[role=search] label { margin-bottom: 0; }
[data-work-results] { margin: .6rem 0; }
.manual { margin-top: .8rem; }
.manual summary { cursor: pointer; min-height: var(--tap); display: flex; align-items: center; font-weight: 600; }
.work-head .cat-title { align-items: flex-start; }
.work-head h1 { overflow-wrap: break-word; hyphens: auto; }
.work-head p { margin: .2rem 0 0; }
.work-line { display: inline-flex; flex-wrap: wrap; align-items: baseline; gap: .1rem .45rem; }
.progress { font-variant-numeric: tabular-nums; font-weight: 700; color: var(--c-ink, var(--ink)); }
.rating { font-size: .85rem; font-weight: 700; color: #a16207; white-space: nowrap; }
@media (prefers-color-scheme: dark) { html:not([data-theme=light]) .rating { color: #fbbf24; } }
html[data-theme=dark] .rating { color: #fbbf24; }
.rating-max { color: var(--muted); font-weight: 500; }
.meta-work { display: block; color: var(--ink); font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.rating-input { margin-bottom: .8rem; }
.rating-chips, .kind-choice { display: flex; flex-wrap: wrap; gap: .3rem; }
.chip { margin: 0; flex: none; position: relative; cursor: pointer; }
.chip input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.chip span {
    display: grid; place-items: center; min-width: var(--tap); min-height: var(--tap); padding: 0 .6rem;
    border: 1px solid var(--field); border-radius: 10px; font-weight: 600; font-variant-numeric: tabular-nums;
}
.chip.wide span { padding: 0 .9rem; font-weight: 500; }
.chip input:checked + span { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.chip input:focus-visible + span { outline: 3px solid var(--focus); outline-offset: 2px; }
.chip, .chip span { -webkit-user-select: none; user-select: none; }
a.tap { text-decoration: none; }
.tap .meta { display: block; width: 100%; min-width: 0; overflow: hidden; }
.tile { min-width: 0; }

.work-title { font-weight: 700; text-decoration: none; overflow-wrap: anywhere; line-height: 1.25; }
.work-title:hover { text-decoration: underline; }
.work-actions { margin: 0 0 1rem; }
.work-actions form { margin: 0; }

.milestone { font-size: .8125rem; font-weight: 700; padding: .05rem .45rem; border-radius: 999px; background: var(--line); }
.dates { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(9rem, 100%), 1fr)); gap: .6rem; margin: 0 0 1rem; }
.dates div { min-width: 0; }
.dates dt { font-size: .8125rem; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.dates dd { margin: 0; font-weight: 600; }
.dates dd.big { font-size: 1.35rem; font-weight: 700; }
.game-status form { margin: 0 0 .5rem; }

.period-list { list-style: none; margin: 0 0 .6rem; padding: 0; }
.period-list li { display: flex; justify-content: space-between; gap: .6rem; padding: .45rem 0; border-top: 1px solid var(--line); font-variant-numeric: tabular-nums; }
.period-list li:first-child { border-top: 0; }
.finish-btn { font-size: 1.2rem; }

/* --- Boutons d'action avec libellé + sous-titre ------------------------------------- */
.work-list li { flex-wrap: wrap; }
.work-btns { display: flex; gap: .4rem; margin-left: auto; flex-wrap: wrap; justify-content: flex-end; }
.work-btns form { margin: 0; }
.next-btn, .finish-btn { flex-direction: column; gap: 0; line-height: 1.15; padding: .35rem .8rem; }
.btn-main { font-weight: 700; white-space: nowrap; }
.btn-sub { font-size: .8125rem; font-weight: 500; white-space: nowrap; }
@media (max-width: 480px) {
    /* Téléphone : deux boutons de même largeur sous le titre, texte autorisé à passer à la ligne. */
    .work-btns { width: 100%; flex-wrap: nowrap; justify-content: stretch; }
    .work-btns form { flex: 1 1 0; min-width: 0; }
    .work-btns .btn { width: 100%; height: 100%; padding: .35rem .5rem; }
    .work-btns .btn-main, .work-btns .btn-sub { white-space: normal; text-align: center; }
}
.work-actions .work-btns { margin-left: 0; justify-content: flex-start; }
.notice { border-left: 4px solid var(--c, var(--accent)); }
.notice p { margin-top: 0; }
.notice form { margin: 0; }

/* --- Aide « ? » ---------------------------------------------------------------------- */
/* La bulle se cale sur le bloc qui contient le « ? » (en-tête de page ou carte), pas sur le bouton :
   elle ne sort jamais de l'écran, même quand le « ? » est à gauche. */
.help-box { position: static; }
.page-head, .card-head, .card { position: relative; }
.help-box > summary {
    list-style: none; cursor: pointer; display: grid; place-items: center;
    width: var(--tap); height: var(--tap); border-radius: 50%; border: 1px solid var(--field);
    font-weight: 700; font-size: 1.05rem; color: var(--muted); background: var(--surface);
}
.help-box > summary::-webkit-details-marker { display: none; }
.help-box[open] > summary { color: var(--ink); border-color: var(--ink); }
.help-pop {
    position: absolute; right: 0; top: calc(100% + .4rem); z-index: 15; width: min(22rem, calc(100vw - 2rem));
    background: var(--surface); color: var(--ink); border: 1px solid var(--line); border-radius: 12px;
    box-shadow: 0 8px 28px rgb(0 0 0 / .18); padding: .8rem 1rem; font-size: .92rem; text-align: left;
}
.help-title { margin: 0 0 .4rem; font-weight: 700; }
.help-pop ul { margin: 0; padding-left: 1.1rem; }
.help-pop li { margin: .3rem 0; }

@media (max-width: 480px) {
    .help-pop { left: 0; right: 0; width: auto; }
}

/* --- En-tête des pages d'œuvre : « ? » à côté du titre, lien vers la fiche ---------- */
.cat-title h1 { min-width: 0; }
.cat-title .help-box { flex: none; }
.head-link {
    display: inline-flex; align-items: center; gap: .1rem; min-height: var(--tap); padding: 0 .2rem 0 .5rem;
    color: var(--muted); font-weight: 600; text-decoration: none; border-radius: 8px; white-space: nowrap;
}
.head-link:hover { color: var(--ink); background: var(--surface); }
.head-link svg.ui { width: 1.2rem; height: 1.2rem; }

/* --- Actions de l'accueil : sur une ligne à part, sous un filet (pas dans le dernier groupe) ---------- */
.home-actions {
    display: flex; flex-wrap: wrap; gap: .6rem; margin-top: 1.4rem; padding-top: 1rem;
    border-top: 1px solid color-mix(in srgb, var(--ink) 22%, var(--bg));
}
.act-btn {
    display: inline-flex; align-items: center; justify-content: center; gap: .45rem; min-height: var(--tap); padding: .4rem 1rem;
    border: 2px dashed color-mix(in srgb, var(--ink) 30%, var(--bg)); border-radius: 12px;
    color: var(--muted); font-weight: 600; text-decoration: none; text-align: center;
    -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
}
.act-btn:hover { color: var(--ink); border-color: var(--ink); background: var(--surface); }
.act-btn svg.ui { width: 1.25rem; height: 1.25rem; }
@media (max-width: 480px) {
    .home-actions { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(9rem, 100%), 1fr)); }
}

/* --- Titre des pages-onglets : lu par les lecteurs d'écran, masqué à l'écran (l'onglet actif le montre déjà) --- */
.tab-title {
    position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* --- Menu (logo, feuille, page) -------------------------------------------------- */
.menu-page.appmenu-panel { position: static; min-width: 0; box-shadow: var(--shadow); padding: .4rem; }
.sheet { display: none; }

/* --- Téléphone : barre d'onglets en bas ------------------------------------------ */
.tabbar { display: none; }
@media (max-width: 640px) {
    body.tabbed .topbar { display: none; }
    body.tabbed main {
        padding-top: max(1rem, env(safe-area-inset-top));
        padding-bottom: calc(5.5rem + env(safe-area-inset-bottom));
    }

    .tabbar {
        display: block; position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
        background: var(--bg);
        padding: 0 env(safe-area-inset-right) max(.45rem, env(safe-area-inset-bottom)) env(safe-area-inset-left);
    }
    /* Dans le navigateur, deux filets délimitent la barre, séparée de celle du navigateur par une bande vide. */
    .tabbar-row {
        display: flex; background: var(--surface);
        border-top: 1px solid color-mix(in srgb, var(--ink) 28%, var(--bg));
        border-bottom: 1px solid color-mix(in srgb, var(--ink) 28%, var(--bg));
    }
    .tabbar a {
        flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .1rem;
        min-height: 3.4rem; padding: .3rem .2rem; text-decoration: none; color: var(--muted);
        font-size: .8125rem; font-weight: 600; line-height: 1.15; text-align: center;
        -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent;
    }
    .tabbar a:focus-visible { outline-offset: -3px; }
    .tab-ico { position: relative; display: grid; place-items: center; width: 3.2rem; height: 1.75rem; border-radius: 999px; }
    .tabbar a[aria-current] { color: var(--ink); }
    .tabbar a[aria-current] .tab-ico { background: color-mix(in srgb, var(--accent) 18%, var(--surface)); color: var(--accent); }
    .tab-dot { position: absolute; top: .1rem; right: .7rem; width: .55rem; height: .55rem; border-radius: 50%; background: var(--accent); border: 2px solid var(--surface); }

    /* Menu : feuille qui monte du bas. */
    .sheet[open] {
        display: block; position: fixed; inset: auto 0 0 0; margin: 0; width: 100%; max-width: none; max-height: 85dvh; overflow-y: auto;
        border: 0; border-top: 1px solid var(--line); border-radius: 18px 18px 0 0;
        background: var(--surface); color: var(--ink);
        padding: .6rem max(.6rem, env(safe-area-inset-right)) max(.8rem, env(safe-area-inset-bottom)) max(.6rem, env(safe-area-inset-left));
        animation: sheet-up .2s ease-out;
    }
    .sheet::backdrop { background: rgb(0 0 0 / .4); }
    .sheet .appmenu-panel { position: static; width: auto; border: 0; box-shadow: none; padding: 0; background: none; }
    .sheet form[method=dialog] { margin: .5rem 0 0; }
    .sheet-close { width: 100%; }
    @keyframes sheet-up { from { transform: translateY(100%); } to { transform: none; } }
}
/* Ouvert depuis l'écran d'accueil (sans barre de navigateur) : un seul filet, la barre va jusqu'en bas. */
@media (max-width: 640px) and (display-mode: standalone) {
    .tabbar { background: var(--surface); padding-bottom: env(safe-area-inset-bottom); }
    .tabbar-row { border-bottom: 0; }
}
@media (forced-colors: active) {
    .tabbar-row { border-top: 1px solid CanvasText; border-bottom: 1px solid CanvasText; }
    .tabbar a[aria-current] { text-decoration: underline; }
}

/* --- Pages secondaires : ✎ à côté du titre, ✕ « fermer » en haut à droite ------------------- */
.page-head:has(.head-tools) { flex-wrap: nowrap; align-items: flex-start; }
.page-head > :first-child { min-width: 0; }
.page-head:has(.head-tools) > .cat-title { flex: 1 1 auto; }
.head-tools { display: flex; align-items: center; gap: .4rem; flex: none; margin-left: auto; }
.close-btn { border: 1px solid var(--field); background: var(--surface); border-radius: 50%; }
.close-btn:hover { border-color: var(--ink); }
.title-line { display: flex; align-items: center; gap: .15rem; min-width: 0; }
.title-line h1 { min-width: 0; }
.edit-btn { flex: none; border-radius: 50%; }
.edit-btn svg.ui { width: 1.25rem; height: 1.25rem; }
@media (max-width: 379px) {
    .poster.md { width: 56px; height: 84px; }
    .head-tools { gap: .2rem; }
}

/* --- Lien « Statistiques et historique » (écran d'une catégorie œuvre) ------------------- */
.stats-link {
    display: flex; align-items: center; gap: .7rem; min-height: 3.5rem; padding: .6rem .8rem .6rem 1rem; margin-bottom: 1rem;
    background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
    text-decoration: none; color: var(--ink);
}
.stats-link:hover { border-color: var(--field); }
.stats-link > svg.ui { color: var(--muted); }
.stats-main { display: block; font-weight: 600; }
.stats-sub { display: block; font-size: .875rem; color: var(--muted); }

/* --- Réorganiser : glisser-déposer, plier / déplier, renommer --------------------------- */
.dnd-on .nojs-move { display: none; }
.order-status:empty { display: none; }
.order-status { margin: 0 0 1rem; padding: .6rem .9rem; border-radius: 10px; background: var(--surface); border-left: 4px solid var(--accent); }
.order-group-head { justify-content: flex-start; flex-wrap: wrap; }
.order-group-head h2 { min-width: 0; overflow-wrap: anywhere; }
.order-group-head .order-buttons { margin-left: auto; }
.rename-btn svg.ui { width: 1.15rem; height: 1.15rem; }
.rename-form { display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; flex: 1 1 14rem; margin: 0; }
.rename-form input[type=text] { flex: 1 1 10rem; width: auto; min-width: 0; }
.fold-btn svg.ui { transition: transform .15s; }
.order-group.folded .fold-btn svg.ui { transform: rotate(-90deg); }
.order-group.folded .order-list { display: none; }
.order-group.folded { margin-bottom: .6rem; }
.order-empty { padding: .8rem; justify-content: center; }
.order-list .order-empty { min-height: 2.8rem; }
.order-list:has(li[data-id]) .order-empty, .order-list:has(.drop-ph) .order-empty { display: none; }
.drag-handle { cursor: grab; touch-action: none; color: var(--muted); }
.drag-handle:active { cursor: grabbing; }
.drag-handle svg.ui { width: 1.45rem; height: 1.45rem; }
body.dragging { -webkit-user-select: none; user-select: none; cursor: grabbing; }
.is-dragging {
    position: fixed !important; z-index: 60; margin: 0 !important; pointer-events: none;
    background: var(--surface); border: 1px solid var(--field) !important; border-radius: 12px;
    box-shadow: 0 10px 30px rgb(0 0 0 / .25); opacity: .96;
}
section.is-dragging { padding: .3rem .6rem; }
.drop-ph {
    list-style: none; border: 2px dashed var(--accent); border-radius: 12px; margin: .2rem;
    background: color-mix(in srgb, var(--accent) 8%, transparent);
}
section.drop-ph { margin: 0 0 .6rem; }
.order-group.drop-into > .order-group-head { outline: 2px dashed var(--accent); outline-offset: 2px; border-radius: 10px; }
.move-menu { border: 1px solid var(--line); border-radius: 16px; background: var(--surface); color: var(--ink); padding: 1rem; width: min(22rem, calc(100vw - 2rem)); }
.move-menu::backdrop { background: rgb(0 0 0 / .4); }
.move-menu-title { font-size: 1.05rem; margin: 0 0 .8rem; }
.move-menu-actions { display: flex; flex-direction: column; gap: .4rem; }
.move-menu-actions p { margin: .6rem 0 .1rem; font-size: .875rem; color: var(--muted); font-weight: 600; }
.move-menu-actions .btn { justify-content: flex-start; width: 100%; }
.move-menu-close { width: 100%; margin-top: .8rem; }
@media (prefers-reduced-motion: reduce) { .fold-btn svg.ui { transition: none; } }

/* --- Apparence des tuiles (Compte › Apparence) -------------------------------------------
   Classes sur <body> : tiles-<style> grad-<dégradé> shape-<forme>. Les couleurs dérivées (--c-solid, --c-on…)
   sont calculées en PHP (Theme::tileVars) pour garder 4,5:1 entre texte et fond quelle que soit la couleur. */
body { --tile-r: var(--radius); --tile-r-tr: var(--radius); }
body.shape-car   { --tile-r: 3px;  --tile-r-tr: 3px; }
body.shape-tres  { --tile-r: 26px; --tile-r-tr: 26px; }
body.shape-un    { --tile-r: 3px 3px 30px 3px; --tile-r-tr: 3px; }
body.shape-casse { --tile-r: 3px;  --tile-r-tr: 3px; }
.tile { border-radius: var(--tile-r); }
.tile .tap:focus-visible { border-radius: var(--tile-r); }
.tile .more { border-radius: 0 var(--tile-r-tr) 0 10px; }
.shape-casse .tile { clip-path: polygon(0 0, 100% 0, 100% calc(100% - 24px), calc(100% - 24px) 100%, 0 100%); }
.shape-casse .tile .tap:focus-visible { outline-offset: -5px; }

/* Styles « pleins » : fond de couleur, texte --c-on (blanc ou foncé selon la couleur). */
.tiles-plein .tile, .tiles-degrade:not(.grad-pastel):not(.grad-voile) .tile {
    background-color: var(--c-solid); color: var(--c-on); border-color: transparent; box-shadow: none;
}
.tiles-plein .tile .tap, .tiles-degrade:not(.grad-pastel):not(.grad-voile) .tile .tap { color: var(--c-on); }
.tiles-plein .tile .tap .meta, .tiles-plein .tile .tap .meta b, .tiles-plein .tile .more,
.tiles-degrade:not(.grad-pastel):not(.grad-voile) .tile .tap .meta,
.tiles-degrade:not(.grad-pastel):not(.grad-voile) .tile .tap .meta b,
.tiles-degrade:not(.grad-pastel):not(.grad-voile) .tile .more { color: var(--c-on); }
.tiles-plein .tile .hidden-mark, .tiles-degrade:not(.grad-pastel):not(.grad-voile) .tile .hidden-mark { color: inherit; }
.tiles-plein .tile .icon, .tiles-degrade:not(.grad-pastel):not(.grad-voile) .tile .icon {
    background: color-mix(in srgb, var(--c-on) 18%, transparent); color: var(--c-on);
}
.tiles-plein .tile .tap:hover, .tiles-degrade:not(.grad-pastel):not(.grad-voile) .tile .tap:hover { background: color-mix(in srgb, var(--c-on) 10%, transparent); }
.tiles-plein .tile .tap:active, .tiles-degrade:not(.grad-pastel):not(.grad-voile) .tile .tap:active { background: color-mix(in srgb, var(--c-on) 18%, transparent); }
.tiles-plein .tile .more:hover, .tiles-degrade:not(.grad-pastel):not(.grad-voile) .tile .more:hover { background: color-mix(in srgb, var(--c-on) 15%, transparent); }
.tiles-plein .tile::before, .tiles-degrade .tile::before, .tiles-coin .tile::before,
.tiles-teinte .tile::before, .tiles-pastille .tile::before { display: none; }

/* Dégradés */
.tiles-degrade.grad-diag .tile { background-image: linear-gradient(135deg, var(--c-solid), var(--c-deep)); }
.tiles-degrade.grad-vert .tile { background-image: linear-gradient(180deg, var(--c-glow), var(--c-deep)); }
.tiles-degrade.grad-lum  .tile { background-image: radial-gradient(circle at 18% 22%, var(--c-glow), var(--c-solid) 45%, var(--c-deep)); }
.tiles-degrade.grad-deux .tile { background-image: linear-gradient(135deg, var(--c-solid), var(--c-hue2)); }
.tiles-degrade.grad-pastel .tile { background: linear-gradient(135deg, var(--c-pastel), var(--c-pastel2)); border-color: transparent; }
.tiles-degrade.grad-pastel .tile .tap, .tiles-degrade.grad-pastel .tile .tap .meta,
.tiles-degrade.grad-pastel .tile .tap .meta b, .tiles-degrade.grad-pastel .tile .more { color: var(--c-pastel-ink); }
.tiles-degrade.grad-pastel .tile .icon { background: rgb(255 255 255 / .6); color: var(--c-pastel-ink); }
.tiles-degrade.grad-voile .tile { background: linear-gradient(90deg, color-mix(in srgb, var(--c) 34%, transparent), transparent 70%), var(--surface); }
@media (prefers-color-scheme: dark) {
    html:not([data-theme=light]) .tiles-degrade.grad-pastel .tile { background: linear-gradient(135deg, color-mix(in srgb, var(--c) 32%, var(--surface)), var(--surface)); border-color: var(--line); }
    html:not([data-theme=light]) .tiles-degrade.grad-pastel .tile .tap, html:not([data-theme=light]) .tiles-degrade.grad-pastel .tile .more { color: var(--ink); }
    html:not([data-theme=light]) .tiles-degrade.grad-pastel .tile .tap .meta { color: var(--muted); }
    html:not([data-theme=light]) .tiles-degrade.grad-pastel .tile .tap .meta b { color: var(--c-ink); }
    html:not([data-theme=light]) .tiles-degrade.grad-pastel .tile .icon { background: color-mix(in srgb, var(--c) 30%, transparent); color: var(--c-ink); }
    html:not([data-theme=light]) .tiles-degrade.grad-voile .tile { background: linear-gradient(90deg, color-mix(in srgb, var(--c) 30%, transparent), transparent 70%), var(--surface); }
}
html[data-theme=dark] .tiles-degrade.grad-pastel .tile { background: linear-gradient(135deg, color-mix(in srgb, var(--c) 32%, var(--surface)), var(--surface)); border-color: var(--line); }
html[data-theme=dark] .tiles-degrade.grad-pastel .tile .tap, html[data-theme=dark] .tiles-degrade.grad-pastel .tile .more { color: var(--ink); }
html[data-theme=dark] .tiles-degrade.grad-pastel .tile .tap .meta { color: var(--muted); }
html[data-theme=dark] .tiles-degrade.grad-pastel .tile .tap .meta b { color: var(--c-ink); }
html[data-theme=dark] .tiles-degrade.grad-pastel .tile .icon { background: color-mix(in srgb, var(--c) 30%, transparent); color: var(--c-ink); }
html[data-theme=dark] .tiles-degrade.grad-voile .tile { background: linear-gradient(90deg, color-mix(in srgb, var(--c) 30%, transparent), transparent 70%), var(--surface); }

/* Coin : triangle de couleur en haut à droite, sous la flèche des détails. */
.tiles-coin .tile::after {
    content: ""; position: absolute; top: 0; right: 0; width: 0; height: 0; pointer-events: none;
    border-top: var(--tap) solid var(--c-solid); border-left: var(--tap) solid transparent;
}
.tiles-coin .tile .more { z-index: 1; color: var(--c-on); place-items: start end; padding: .2rem .25rem 0 0; }
.tiles-coin .tile .more svg.ui { width: 1.15rem; height: 1.15rem; }
.tiles-coin .tile .more:hover { background: none; color: var(--c-on); }

/* Teinté : fond légèrement coloré, contour de la couleur. */
.tiles-teinte .tile { background: color-mix(in srgb, var(--c) 12%, var(--surface)); border: 2px solid var(--c-ink); box-shadow: none; }
.tiles-teinte .tile .tap .meta, .tiles-teinte .tile .tap .meta b { color: var(--c-tint-ink); }
.tiles-teinte .tile .icon { background: var(--c-solid); color: var(--c-on); }
@media (prefers-color-scheme: dark) {
    html:not([data-theme=light]) .tiles-teinte .tile { background: color-mix(in srgb, var(--c) 22%, var(--surface)); }
    html:not([data-theme=light]) .tiles-teinte .tile .tap .meta, html:not([data-theme=light]) .tiles-teinte .tile .tap .meta b { color: var(--c-ink); }
}
html[data-theme=dark] .tiles-teinte .tile { background: color-mix(in srgb, var(--c) 22%, var(--surface)); }
html[data-theme=dark] .tiles-teinte .tile .tap .meta, html[data-theme=dark] .tiles-teinte .tile .tap .meta b { color: var(--c-ink); }

/* Pastille : grande icône ronde colorée à gauche du texte. */
.tiles-pastille .tile .tap {
    display: grid; grid-template-columns: auto minmax(0, 1fr); grid-template-rows: 1fr auto auto 1fr;
    column-gap: .75rem; align-items: center; padding-left: .9rem;
}
.tiles-pastille .tile .icon {
    grid-row: 1 / -1; width: 3.1rem; height: 3.1rem; border-radius: 50%; font-size: 1.45rem;
    background: var(--c-solid); color: var(--c-on);
}
.tiles-pastille .tile .icon svg { width: 1.6rem; height: 1.6rem; }
.tiles-pastille .tile .name { grid-column: 2; grid-row: 2; }
.tiles-pastille .tile .meta { grid-column: 2; grid-row: 3; margin-top: .15rem; }
@media (max-width: 379px) {
    .tiles-pastille .tile .icon { width: 2.5rem; height: 2.5rem; font-size: 1.2rem; }
}

/* Contrastes forcés : on revient à l'affichage système. */
@media (forced-colors: active) {
    .tile { background: Canvas !important; border: 1px solid CanvasText !important; }
    .tiles-coin .tile::after { display: none; }
}

/* --- Compte › Apparence ------------------------------------------------------------------- */
.appearance fieldset { border: 0; padding: 0; margin: 0 0 1rem; }
.appearance .chips { display: flex; flex-wrap: wrap; gap: .4rem; }
.appearance .chip span { min-width: auto; padding: 0 .9rem; }
.appearance-preview { margin: .4rem 0 1rem; padding: .8rem; border-radius: 12px; background: var(--bg); }
.appearance-preview .tap { cursor: default; }
.legend-like { font-size: .9rem; font-weight: 600; margin: 0 0 .2rem; }

/* --- Page Apparence : vignettes illustrées --------------------------------------------- */
.appearance .appearance-preview { position: sticky; top: max(.4rem, env(safe-area-inset-top)); z-index: 5; margin: 0 0 1rem; padding: .7rem; border-radius: 14px; background: var(--bg); box-shadow: 0 6px 18px rgb(0 0 0 / .12); }
.app-sec { border: 1px solid var(--line); }
.app-legend { display: flex; align-items: center; gap: .55rem; font-size: 1rem; font-weight: 700; padding: 0; margin-bottom: .8rem; float: left; width: 100%; }
.app-legend + * { clear: both; }
.app-legend-ic { display: grid; place-items: center; width: 2rem; height: 2rem; border-radius: 9px; background: color-mix(in srgb, var(--accent) 16%, var(--surface)); color: var(--accent); }
.app-legend-ic svg.ui { width: 1.15rem; height: 1.15rem; }
.app-opts { display: grid; grid-template-columns: repeat(auto-fill, minmax(5.6rem, 1fr)); gap: .55rem; margin-bottom: .4rem; }
.app-opt { position: relative; display: flex; flex-direction: column; align-items: stretch; gap: .35rem; margin: 0; padding: .45rem .45rem .4rem;
    border: 2px solid transparent; border-radius: 12px; cursor: pointer; font-weight: 500; font-size: .875rem; text-align: center; min-height: var(--tap); }
.app-opt input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.app-opt:hover { background: var(--bg); }
.app-opt:has(input:checked) { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 7%, transparent); }
.app-opt:has(input:checked)::after {
    content: "✓"; position: absolute; top: -.45rem; right: -.45rem; width: 1.3rem; height: 1.3rem; border-radius: 50%;
    display: grid; place-items: center; background: var(--accent); color: var(--surface); font-size: .8rem; font-weight: 700;
}
.app-opt:has(input:focus-visible) { outline: 3px solid var(--focus); outline-offset: 2px; }
.app-opt-label { line-height: 1.2; }
.vis { position: relative; display: block; height: 2.7rem; border-radius: 9px; overflow: hidden; background: var(--surface); border: 1px solid var(--line); }
.vis-ic { position: absolute; left: .45rem; top: .45rem; width: .8rem; height: .8rem; border-radius: 3px; background: color-mix(in srgb, var(--c) 25%, transparent); }
/* Thème */
.vis-theme-auto { background: linear-gradient(90deg, #f7f4ee 50%, #211e1b 50%); }
.vis-theme-clair { background: #f7f4ee; border-color: #e7e1d6; }
.vis-theme-sombre { background: #211e1b; border-color: #36312c; }
.vis[class*="vis-theme-"] .vis-ic { display: none; }
.vis[class*="vis-theme-"]::after { content: "Aa"; position: absolute; inset: 0; display: grid; place-items: center; font-weight: 700; font-size: 1rem; }
.vis-theme-auto::after { background: linear-gradient(90deg, #1c1917 50%, #f1ede6 50%); -webkit-background-clip: text; background-clip: text; color: transparent; }
.vis-theme-clair::after { color: #1c1917; }
.vis-theme-sombre::after { color: #f1ede6; }
/* Styles */
.vis-style-lisere { box-shadow: inset 5px 0 0 var(--c); }
.vis-style-plein, .vis-style-degrade, .vis-grad-diag, .vis-grad-vert, .vis-grad-lum, .vis-grad-deux { border-color: transparent; }
.vis-style-plein { background: var(--c-solid); }
.vis-style-degrade, .vis-grad-diag { background: linear-gradient(135deg, var(--c-solid), var(--c-deep)); }
.vis-grad-vert { background: linear-gradient(180deg, var(--c-glow), var(--c-deep)); }
.vis-grad-lum { background: radial-gradient(circle at 18% 22%, var(--c-glow), var(--c-solid) 45%, var(--c-deep)); }
.vis-grad-deux { background: linear-gradient(135deg, var(--c-solid), var(--c-hue2)); }
.vis-grad-pastel { background: linear-gradient(135deg, var(--c-pastel), var(--c-pastel2)); }
.vis-grad-voile { background: linear-gradient(90deg, color-mix(in srgb, var(--c) 40%, transparent), transparent 75%), var(--surface); }
.vis-style-plein .vis-ic, .vis-style-degrade .vis-ic, .vis-grad-diag .vis-ic, .vis-grad-vert .vis-ic, .vis-grad-lum .vis-ic, .vis-grad-deux .vis-ic { background: color-mix(in srgb, var(--c-on) 30%, transparent); }
.vis-style-coin::after { content: ""; position: absolute; top: 0; right: 0; border-top: 1.2rem solid var(--c-solid); border-left: 1.2rem solid transparent; }
.vis-style-teinte { background: color-mix(in srgb, var(--c) 12%, var(--surface)); border: 2px solid var(--c-ink); }
.vis-style-teinte .vis-ic { background: var(--c-solid); }
.vis-style-pastille .vis-ic { top: 50%; left: .45rem; width: 1.6rem; height: 1.6rem; border-radius: 50%; transform: translateY(-50%); background: var(--c-solid); }
/* Formes */
.vis[class*="vis-shape-"] { background: none; border: 0; display: grid; place-items: center; }
.vis[class*="vis-shape-"] .vis-ic { position: static; width: 2.6rem; height: 2rem; background: var(--c-solid); }
.vis-shape-arr .vis-ic { border-radius: 8px; }
.vis-shape-car .vis-ic { border-radius: 2px; }
.vis-shape-tres .vis-ic { border-radius: 14px; }
.vis-shape-un .vis-ic { border-radius: 2px 2px 14px 2px; }
.vis-shape-casse .vis-ic { border-radius: 2px; clip-path: polygon(0 0, 100% 0, 100% calc(100% - .7rem), calc(100% - .7rem) 100%, 0 100%); }
@media (forced-colors: active) { .app-opt:has(input:checked) { outline: 2px solid Highlight; } }

/* Bâton daté de plus tard */
.badge.upcoming { display: block; width: max-content; margin-top: .15rem; background: color-mix(in srgb, var(--accent) 15%, var(--surface)); color: var(--ink); }

/* --- Import en étapes, Exporter -------------------------------------------------------- */
.steps { display: flex; gap: .35rem; list-style: none; padding: 0; margin: 0 0 1rem; }
.steps li { flex: 1; height: 5px; border-radius: 3px; background: var(--line); }
.steps li.on { background: var(--accent); }
.step-q { font-weight: 700; font-size: 1.05rem; margin: 0 0 .8rem; }
.choice-list { display: flex; flex-direction: column; gap: .6rem; margin-bottom: 1rem; }
.choice-card {
    display: flex; align-items: center; gap: .8rem; padding: .9rem 1rem; min-height: var(--tap);
    background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
    color: var(--ink); text-decoration: none;
}
.choice-card:hover { border-color: var(--field); }
.choice-card b { display: block; font-size: 1.05rem; }
.choice-card .muted { display: block; font-size: .9rem; }
.choice-card > svg.ui { color: var(--muted); flex: none; }
.choice-ic { display: grid; place-items: center; width: 2.6rem; height: 2.6rem; flex: none; border-radius: 12px; background: color-mix(in srgb, var(--accent) 15%, var(--surface)); color: var(--accent); }
.choice-ic svg.ui { width: 1.4rem; height: 1.4rem; }
.file-list { list-style: none; padding: 0; margin: 0 0 1rem; }
.file-list li { display: flex; flex-wrap: wrap; justify-content: space-between; gap: .2rem .8rem; padding: .5rem 0; border-top: 1px solid var(--line); font-size: .9rem; }
.file-list li span:first-child { display: inline-flex; align-items: center; gap: .4rem; overflow-wrap: anywhere; }
.file-list li.ok span:first-child svg.ui { color: #15803d; }
.drop-zone {
    position: relative; display: flex; flex-direction: column; align-items: center; gap: .4rem; text-align: center;
    padding: 1.3rem 1rem; border: 2px dashed color-mix(in srgb, var(--ink) 30%, var(--bg)); border-radius: 14px; cursor: pointer; font-weight: 400;
}
.drop-zone:hover, .drop-zone:focus-within { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 6%, transparent); }
.drop-zone > svg.ui { width: 1.8rem; height: 1.8rem; color: var(--accent); }
.drop-zone b { display: block; font-size: 1.05rem; }
.drop-zone input[type=file] { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; }
.drop-zone:focus-within { outline: 3px solid var(--focus); outline-offset: 2px; }
.summary { margin: .4rem 0 1rem; }
.summary > div { display: flex; justify-content: space-between; gap: 1rem; padding: .45rem 0; border-top: 1px solid var(--line); }
.summary dt { margin: 0; }
.summary dd { margin: 0; font-weight: 700; font-variant-numeric: tabular-nums; }
.summary-names { margin: -.2rem 0 .3rem; color: var(--muted); font-size: .9rem; }
.export-note { display: block; padding: .6rem .8rem; border-radius: 10px; background: color-mix(in srgb, var(--accent) 10%, var(--surface)); }
.export-cat { display: block; margin: .4rem 0 0 2rem; }
.export-cat select { width: 100%; max-width: 22rem; }
.export-note > svg.ui { width: 1.1em; height: 1.1em; vertical-align: -.15em; margin-right: .3rem; }
