/* ==========================================================================
   CartoForge — feuille de style principale
   ========================================================================== */

/* ---------- Tokens ---------- */
:root {
    --font-sans: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
    --font-display: 'Space Grotesk', 'Inter', system-ui, sans-serif;
    --font-mono: 'JetBrains Mono', ui-monospace, 'Cascadia Code', Consolas, monospace;

    --radius-s: 10px;
    --radius: 16px;
    --radius-l: 24px;
    --container: 1200px;
    --header-h: 68px;
    --ease: cubic-bezier(.2, .8, .2, 1);

    /* Couleurs d'accent (communes aux thèmes) */
    --teal: #2ee6c5;
    --violet: #8b6cff;
    --blue: #4ea8ff;
    --amber: #ffb547;
    --pink: #ff6fb5;
    --lime: #b6f04a;
    --grad: linear-gradient(120deg, var(--teal) 0%, var(--blue) 45%, var(--violet) 100%);
}

/* Thème sombre (défaut) */
:root,
:root[data-theme="dark"] {
    color-scheme: dark;
    --bg: #060910;
    --bg-2: #0a0f1a;
    --bg-3: #0f1624;
    --surface: rgba(255, 255, 255, .035);
    --surface-2: rgba(255, 255, 255, .06);
    --surface-solid: #0d1320;
    --border: rgba(255, 255, 255, .08);
    --border-strong: rgba(255, 255, 255, .16);
    --text: #e9eef6;
    --text-2: #b4bfd0;
    --muted: #7d8aa0;
    --accent: var(--teal);
    --accent-ink: #04201b;
    --contour: rgba(140, 170, 210, .10);
    --contour-strong: rgba(140, 170, 210, .22);
    --shadow: 0 20px 60px -20px rgba(0, 0, 0, .6);
    --glow: 0 0 0 1px rgba(46, 230, 197, .25), 0 10px 40px -10px rgba(46, 230, 197, .35);
    --code-bg: #0b111d;
}

:root[data-theme="light"] {
    color-scheme: light;
    --bg: #f5f7fb;
    --bg-2: #eef2f8;
    --bg-3: #e6ebf3;
    --surface: rgba(255, 255, 255, .7);
    --surface-2: rgba(255, 255, 255, .95);
    --surface-solid: #ffffff;
    --border: rgba(15, 30, 60, .09);
    --border-strong: rgba(15, 30, 60, .18);
    --text: #0c1424;
    --text-2: #3a4760;
    --muted: #66738a;
    --accent: #0bb89a;
    --accent-ink: #ffffff;
    --teal: #0bb89a;
    --violet: #6d4cff;
    --blue: #2a7fe0;
    --amber: #e08a00;
    --pink: #e0479a;
    --lime: #5c9e0a;
    --contour: rgba(40, 70, 120, .10);
    --contour-strong: rgba(40, 70, 120, .22);
    --shadow: 0 20px 50px -25px rgba(20, 40, 80, .35);
    --glow: 0 0 0 1px rgba(11, 184, 154, .3), 0 10px 40px -12px rgba(11, 184, 154, .35);
    --code-bg: #0e1522;
}

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
    margin: 0;
    font-family: var(--font-sans);
    font-size: 16px;
    line-height: 1.65;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
    transition: background-color .3s, color .3s;
}
img, svg, canvas { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3, h4 { font-family: var(--font-display); line-height: 1.15; margin: 0 0 .5em; letter-spacing: -.02em; font-weight: 600; }
p { margin: 0 0 1em; }
::selection { background: color-mix(in srgb, var(--accent) 35%, transparent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 6px; }

.icon { width: 1.15em; height: 1.15em; flex-shrink: 0; }
.mono { font-family: var(--font-mono); font-size: .85em; }
.container { width: 100%; max-width: var(--container); margin: 0 auto; padding: 0 24px; }
[hidden] { display: none !important; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* Grain subtil */
.noise {
    position: fixed; inset: 0; z-index: 100; pointer-events: none; opacity: .035;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* ---------- Header ---------- */
.site-header {
    position: sticky; top: 0; z-index: 50;
    height: var(--header-h);
    background: color-mix(in srgb, var(--bg) 70%, transparent);
    backdrop-filter: saturate(160%) blur(16px);
    -webkit-backdrop-filter: saturate(160%) blur(16px);
    border-bottom: 1px solid transparent;
    transition: border-color .3s, background .3s;
}
.site-header.is-scrolled { border-bottom-color: var(--border); }
.site-header__inner { height: 100%; display: flex; align-items: center; gap: 24px; }

.brand { display: inline-flex; align-items: center; gap: 10px; font-family: var(--font-display); font-size: 1.2rem; font-weight: 500; letter-spacing: -.02em; }
.brand b { font-weight: 700; background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.brand__logo {
    width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center;
    background: var(--surface-2); border: 1px solid var(--border);
}
.brand__logo svg { width: 24px; height: 24px; fill: none; stroke: var(--accent); stroke-width: 2.4; stroke-linecap: round; }
.brand__logo circle { fill: var(--violet); stroke: none; }

.main-nav { display: flex; gap: 4px; margin-left: 12px; }
.main-nav a {
    position: relative; padding: 8px 14px; border-radius: 999px;
    color: var(--text-2); font-size: .94rem; font-weight: 500; transition: color .2s, background .2s;
}
.main-nav a:hover { color: var(--text); background: var(--surface-2); }
.main-nav a.is-active { color: var(--text); background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--border); }
.main-nav a.is-active::after {
    content: ''; position: absolute; left: 50%; bottom: 3px; width: 4px; height: 4px; margin-left: -2px;
    border-radius: 50%; background: var(--accent); box-shadow: 0 0 10px var(--accent);
}

.header-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.search-trigger {
    display: flex; align-items: center; gap: 10px; height: 40px; padding: 0 8px 0 14px;
    border-radius: 999px; border: 1px solid var(--border); background: var(--surface);
    color: var(--muted); font-size: .9rem; min-width: 220px; transition: border-color .2s, background .2s;
}
.search-trigger:hover { border-color: var(--border-strong); background: var(--surface-2); }
.search-trigger span { flex: 1; text-align: left; }
kbd {
    font-family: var(--font-mono); font-size: .72rem; padding: 3px 7px; border-radius: 6px;
    border: 1px solid var(--border); background: var(--surface-2); color: var(--muted);
}
.icon-btn {
    width: 40px; height: 40px; display: grid; place-items: center; border-radius: 12px;
    border: 1px solid var(--border); background: var(--surface); transition: background .2s, transform .2s;
}
.icon-btn:hover { background: var(--surface-2); }
.icon-btn:active { transform: scale(.94); }
[data-theme="dark"] .i-light, [data-theme="light"] .i-dark { display: none; }
.menu-btn { display: none; }

/* ---------- Boutons ---------- */
.btn {
    --b-bg: var(--surface-2);
    display: inline-flex; align-items: center; justify-content: center; gap: 10px;
    height: 48px; padding: 0 22px; border-radius: 999px; border: 1px solid var(--border);
    background: var(--b-bg); font-weight: 600; font-size: .95rem; white-space: nowrap;
    transition: transform .25s var(--ease), box-shadow .25s, background .25s, border-color .25s;
}
.btn:hover { transform: translateY(-2px); border-color: var(--border-strong); }
.btn .icon { transition: transform .25s var(--ease); }
.btn:hover .icon { transform: translateX(3px); }
.btn--primary {
    border: 0; color: #04140f;
    background: linear-gradient(120deg, var(--teal), #7cf0dc 50%, var(--teal));
    background-size: 200% 100%;
    box-shadow: 0 10px 30px -10px color-mix(in srgb, var(--teal) 70%, transparent), inset 0 1px 0 rgba(255,255,255,.5);
}
.btn--primary:hover { background-position: 100% 0; box-shadow: 0 16px 40px -12px color-mix(in srgb, var(--teal) 80%, transparent); }
.btn--sm { height: 38px; padding: 0 16px; font-size: .86rem; }
.btn--ghost { background: transparent; }

/* ---------- Typo utilitaires ---------- */
.eyebrow {
    display: inline-flex; align-items: center; gap: 8px;
    font-family: var(--font-mono); font-size: .78rem; text-transform: uppercase; letter-spacing: .12em;
    color: var(--accent);
}
.eyebrow::before { content: ''; width: 18px; height: 1px; background: currentColor; }
.grad-text { background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.section { padding: 110px 0; position: relative; }
.section--tight { padding: 70px 0; }
.section-head { display: flex; align-items: end; justify-content: space-between; gap: 24px; margin-bottom: 48px; flex-wrap: wrap; }
.section-head h2 { font-size: clamp(2rem, 4vw, 3rem); margin: 12px 0 0; max-width: 18ch; }
.section-head p { color: var(--text-2); max-width: 46ch; margin: 0; }
.link-arrow { display: inline-flex; align-items: center; gap: 6px; color: var(--accent); font-weight: 600; font-size: .92rem; }
.link-arrow .icon { transition: transform .25s var(--ease); }
a:hover .link-arrow .icon, .link-arrow:hover .icon { transform: translateX(4px); }

/* ---------- Hero ---------- */
.hero {
    position: relative; min-height: calc(100vh - var(--header-h)); min-height: calc(100svh - var(--header-h));
    display: flex; align-items: center; overflow: hidden; isolation: isolate;
    margin-top: calc(var(--header-h) * -1); padding-top: var(--header-h);
}
.hero__canvas { position: absolute; inset: 0; width: 100%; height: 100%; z-index: -2; }
.hero::before {
    content: ''; position: absolute; inset: 0; z-index: -1; pointer-events: none;
    background:
        radial-gradient(60% 50% at 20% 30%, color-mix(in srgb, var(--teal) 14%, transparent), transparent 70%),
        radial-gradient(50% 50% at 85% 70%, color-mix(in srgb, var(--violet) 16%, transparent), transparent 70%),
        linear-gradient(to bottom, transparent 60%, var(--bg));
}
.hero__inner { position: relative; padding: 80px 24px 120px; }
.hero__badge {
    display: inline-flex; align-items: center; gap: 10px; padding: 6px 14px 6px 6px; border-radius: 999px;
    background: var(--surface); border: 1px solid var(--border); backdrop-filter: blur(10px);
    font-size: .86rem; color: var(--text-2); margin-bottom: 28px;
}
.hero__badge b {
    padding: 3px 10px; border-radius: 999px; font-size: .74rem; font-weight: 600; letter-spacing: .02em;
    background: var(--grad); color: #fff;
}
.hero h1 {
    font-size: clamp(2.8rem, 8vw, 6.2rem); font-weight: 700; line-height: .98; letter-spacing: -.045em;
    max-width: 13ch; margin-bottom: 28px;
}
.hero h1 em { font-style: normal; }
.hero__lead { font-size: clamp(1.05rem, 1.6vw, 1.25rem); color: var(--text-2); max-width: 52ch; margin-bottom: 40px; }
.hero__cta { display: flex; gap: 12px; flex-wrap: wrap; }
.hero__stats { display: flex; gap: 48px; margin-top: 72px; flex-wrap: wrap; }
.stat strong { display: block; font-family: var(--font-display); font-size: 2.2rem; font-weight: 600; letter-spacing: -.03em; line-height: 1; }
.stat span { font-size: .85rem; color: var(--muted); }

.hud {
    position: absolute; right: 24px; bottom: 40px; z-index: 2;
    display: grid; gap: 4px; padding: 14px 16px; border-radius: var(--radius);
    background: color-mix(in srgb, var(--bg) 55%, transparent); backdrop-filter: blur(12px);
    border: 1px solid var(--border); font-family: var(--font-mono); font-size: .76rem; color: var(--muted);
    min-width: 230px;
}
.hud div { display: flex; justify-content: space-between; gap: 18px; }
.hud b { color: var(--text); font-weight: 500; }
.hud__title { color: var(--accent) !important; display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.hud__title::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 10px var(--accent); animation: pulse 2s infinite; }
@keyframes pulse { 50% { opacity: .3; } }

/* ---------- Marquee ---------- */
.marquee {
    position: relative; overflow: hidden; padding: 26px 0; border-block: 1px solid var(--border);
    mask-image: linear-gradient(90deg, transparent, #000 12%, #000 88%, transparent);
    -webkit-mask-image: linear-gradient(90deg, transparent, #000 12%, #000 88%, transparent);
}
.marquee__track { display: flex; gap: 56px; width: max-content; animation: marquee 40s linear infinite; }
.marquee__track span { font-family: var(--font-display); font-size: 1.35rem; font-weight: 500; color: var(--muted); white-space: nowrap; display: flex; align-items: center; gap: 56px; }
.marquee__track span::after { content: '✦'; font-size: .8rem; color: var(--accent); opacity: .6; }
@keyframes marquee { to { transform: translateX(-50%); } }

/* ---------- Cartes génériques ---------- */
.card {
    --mx: 50%; --my: 50%;
    position: relative; display: block; border-radius: var(--radius-l);
    background: var(--surface); border: 1px solid var(--border);
    transition: transform .35s var(--ease), border-color .35s, box-shadow .35s, background .35s;
    overflow: hidden; isolation: isolate;
}
.card::before {
    /* projecteur qui suit la souris */
    content: ''; position: absolute; inset: 0; z-index: -1; opacity: 0; transition: opacity .35s;
    background: radial-gradient(420px circle at var(--mx) var(--my), color-mix(in srgb, var(--accent) 12%, transparent), transparent 45%);
}
.card:hover { border-color: var(--border-strong); transform: translateY(-4px); box-shadow: var(--shadow); }
.card:hover::before { opacity: 1; }

/* Couleurs de ton */
.tone-teal   { --tone: var(--teal); }
.tone-violet { --tone: var(--violet); }
.tone-blue   { --tone: var(--blue); }
.tone-amber  { --tone: var(--amber); }
.tone-pink   { --tone: var(--pink); }
.tone-lime   { --tone: var(--lime); }

.chip {
    display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px;
    font-size: .74rem; font-weight: 600; letter-spacing: .02em;
    color: var(--c, var(--accent)); background: color-mix(in srgb, var(--c, var(--accent)) 12%, transparent);
    border: 1px solid color-mix(in srgb, var(--c, var(--accent)) 25%, transparent);
}
.chip--teal { --c: var(--teal); } .chip--violet { --c: var(--violet); } .chip--blue { --c: var(--blue); }
.chip--amber { --c: var(--amber); } .chip--pink { --c: var(--pink); } .chip--lime { --c: var(--lime); }
.tag { font-family: var(--font-mono); font-size: .72rem; padding: 3px 8px; border-radius: 6px; background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); }

.level { display: inline-flex; align-items: center; gap: 3px; font-size: .78rem; color: var(--muted); }
.level i { width: 4px; border-radius: 2px; background: var(--border-strong); }
.level i:nth-child(1) { height: 7px; } .level i:nth-child(2) { height: 10px; } .level i:nth-child(3) { height: 13px; margin-right: 5px; }
.lvl-1 i:nth-child(-n+1), .lvl-2 i:nth-child(-n+2), .lvl-3 i:nth-child(-n+3) { background: var(--accent); }

/* ---------- Bento ---------- */
.bento { display: grid; grid-template-columns: repeat(6, 1fr); grid-auto-rows: minmax(220px, auto); gap: 16px; }
.bento .card { padding: 32px; display: flex; flex-direction: column; }
.bento h3 { font-size: 1.5rem; margin-bottom: 8px; }
.bento p { color: var(--text-2); margin: 0; max-width: 42ch; }
.bento__a { grid-column: span 4; grid-row: span 2; }
.bento__b { grid-column: span 2; }
.bento__c { grid-column: span 2; }
.bento__d { grid-column: span 3; }
.bento__e { grid-column: span 3; }
.bento__icon {
    width: 48px; height: 48px; border-radius: 14px; display: grid; place-items: center; margin-bottom: auto;
    color: var(--tone); background: color-mix(in srgb, var(--tone) 12%, transparent);
    border: 1px solid color-mix(in srgb, var(--tone) 25%, transparent);
}
.bento__icon .icon { width: 24px; height: 24px; }
.bento .card > div:last-child { margin-top: 28px; }
.bento__big-num { font-family: var(--font-display); font-size: 4.5rem; font-weight: 700; letter-spacing: -.05em; line-height: 1; margin: 24px 0 auto; }
.mini-map { position: relative; flex: 1; margin: 8px -32px 0; min-height: 260px; overflow: hidden; }
.mini-map svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.mini-map .contour { fill: none; stroke: var(--contour-strong); stroke-width: 1.2; }
.mini-map .route { fill: none; stroke: var(--accent); stroke-width: 3; stroke-linecap: round; stroke-dasharray: 8 10; animation: dash 30s linear infinite; filter: drop-shadow(0 0 6px var(--accent)); }
.mini-map .poi { fill: var(--bg); stroke: var(--violet); stroke-width: 3; }
@keyframes dash { to { stroke-dashoffset: -600; } }
.code-snip {
    font-family: var(--font-mono); font-size: .8rem; line-height: 1.7; padding: 16px 18px; border-radius: 14px;
    background: var(--code-bg); color: #c7d2e4; border: 1px solid var(--border); overflow: hidden; white-space: pre;
}
.code-snip .k { color: #ff8fc7; } .code-snip .s { color: #8ef0d8; } .code-snip .n { color: #ffcf7a; } .code-snip .c { color: #6b7a93; }
.swatches { display: flex; gap: 6px; margin-top: 28px; }
.swatches i { flex: 1; height: 44px; border-radius: 10px; transition: transform .3s var(--ease); }
.card:hover .swatches i { transform: translateY(-4px); }
.card:hover .swatches i:nth-child(2) { transition-delay: .03s; } .card:hover .swatches i:nth-child(3) { transition-delay: .06s; }
.card:hover .swatches i:nth-child(4) { transition-delay: .09s; } .card:hover .swatches i:nth-child(5) { transition-delay: .12s; }

/* ---------- Cartes tutoriels ---------- */
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 20px; }
.tuto-card { display: flex; flex-direction: column; }
.tuto-card__visual {
    position: relative; height: 150px; overflow: hidden;
    background:
        radial-gradient(120% 120% at 100% 100%, color-mix(in srgb, var(--tone) 28%, transparent), transparent 60%),
        var(--bg-2);
    border-bottom: 1px solid var(--border);
}
.tuto-card__contours { position: absolute; inset: 0; width: 100%; height: 100%; }
.tuto-card__contours ellipse { fill: none; stroke: color-mix(in srgb, var(--tone) 45%, transparent); stroke-width: .6; vector-effect: non-scaling-stroke; transition: transform .8s var(--ease); transform-origin: 75% 60%; }
.tuto-card:hover .tuto-card__contours ellipse { transform: scale(1.12) rotate(-4deg); }
.tuto-card__icon {
    position: absolute; left: 22px; bottom: 18px; width: 52px; height: 52px; border-radius: 16px;
    display: grid; place-items: center; color: var(--tone);
    background: color-mix(in srgb, var(--bg) 70%, transparent); backdrop-filter: blur(6px);
    border: 1px solid color-mix(in srgb, var(--tone) 35%, transparent);
    box-shadow: 0 0 30px -6px color-mix(in srgb, var(--tone) 60%, transparent);
}
.tuto-card__icon .icon { width: 26px; height: 26px; }
.tuto-card__body { padding: 22px 24px 24px; display: flex; flex-direction: column; flex: 1; }
.tuto-card__meta { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; gap: 8px; }
.tuto-card h3 { font-size: 1.22rem; margin-bottom: 8px; }
.tuto-card p { color: var(--text-2); font-size: .93rem; margin-bottom: 20px; }
.tuto-card__foot { margin-top: auto; display: flex; justify-content: space-between; align-items: center; font-size: .85rem; color: var(--muted); }
.tuto-card__foot > span:first-child { display: inline-flex; align-items: center; gap: 6px; }

/* ---------- Cartes outils ---------- */
.tool-card { padding: 28px; }
.tool-card__icon {
    width: 52px; height: 52px; border-radius: 16px; display: grid; place-items: center; margin-bottom: 22px;
    color: var(--tone); background: color-mix(in srgb, var(--tone) 12%, transparent);
    border: 1px solid color-mix(in srgb, var(--tone) 25%, transparent);
    transition: transform .4s var(--ease);
}
.tool-card__icon .icon { width: 26px; height: 26px; }
.tool-card:hover .tool-card__icon { transform: rotate(-8deg) scale(1.06); }
.tool-card h3 { font-size: 1.2rem; margin-bottom: 8px; padding-right: 40px; }
.tool-card p { color: var(--text-2); font-size: .93rem; margin-bottom: 18px; }
.tool-card__tags { display: flex; gap: 6px; flex-wrap: wrap; }
.tool-card__go {
    position: absolute; top: 24px; right: 24px; width: 36px; height: 36px; border-radius: 50%;
    display: grid; place-items: center; border: 1px solid var(--border); color: var(--muted);
    transition: all .35s var(--ease);
}
.tool-card:hover .tool-card__go { background: var(--accent); color: var(--accent-ink); border-color: transparent; transform: rotate(-45deg); }

/* ---------- Parcours ---------- */
.path { display: grid; grid-template-columns: repeat(5, 1fr); gap: 16px; position: relative; counter-reset: step; }
.path::before {
    content: ''; position: absolute; top: 27px; left: 10%; right: 10%; height: 2px;
    background: linear-gradient(90deg, var(--teal), var(--blue), var(--violet), var(--pink), var(--lime)); opacity: .5;
}
.path__step { position: relative; text-align: center; padding: 0 6px; }
.path__dot {
    width: 56px; height: 56px; margin: 0 auto 18px; border-radius: 50%; display: grid; place-items: center;
    background: var(--bg); border: 2px solid var(--tone); color: var(--tone); position: relative;
    box-shadow: 0 0 0 6px var(--bg), 0 0 30px -4px color-mix(in srgb, var(--tone) 60%, transparent);
    transition: transform .3s var(--ease);
}
.path__step:hover .path__dot { transform: scale(1.1); }
.path__step h4 { font-size: 1.05rem; margin-bottom: 4px; }
.path__step p { font-size: .86rem; color: var(--muted); margin: 0; }
.path__step small { display: block; font-family: var(--font-mono); font-size: .7rem; color: var(--tone); margin-bottom: 4px; letter-spacing: .1em; }

/* ---------- CTA ---------- */
.cta {
    position: relative; overflow: hidden; border-radius: 32px; padding: clamp(40px, 7vw, 90px);
    background: radial-gradient(80% 120% at 0% 0%, color-mix(in srgb, var(--teal) 22%, transparent), transparent 60%),
                radial-gradient(80% 120% at 100% 100%, color-mix(in srgb, var(--violet) 26%, transparent), transparent 60%),
                var(--bg-2);
    border: 1px solid var(--border); text-align: center; isolation: isolate;
}
.cta canvas { position: absolute; inset: 0; width: 100%; height: 100%; z-index: -1; opacity: .7; }
.cta h2 { font-size: clamp(2rem, 5vw, 3.6rem); max-width: 16ch; margin: 0 auto 18px; }
.cta p { color: var(--text-2); max-width: 50ch; margin: 0 auto 32px; }
.cta .hero__cta { justify-content: center; }

/* ---------- En-têtes de pages ---------- */
.page-hero { position: relative; padding: 80px 0 50px; overflow: hidden; isolation: isolate; }
.page-hero canvas { position: absolute; inset: 0; width: 100%; height: 100%; z-index: -2; opacity: .8; }
.page-hero::after { content: ''; position: absolute; inset: 0; z-index: -1; background: linear-gradient(to bottom, transparent 30%, var(--bg)); }
.page-hero h1 { font-size: clamp(2.4rem, 6vw, 4.4rem); font-weight: 700; letter-spacing: -.04em; margin: 16px 0 16px; max-width: 18ch; }
.page-hero p { font-size: 1.12rem; color: var(--text-2); max-width: 60ch; margin: 0; }
.breadcrumb { display: flex; align-items: center; gap: 8px; font-size: .85rem; color: var(--muted); flex-wrap: wrap; }
.breadcrumb a:hover { color: var(--text); }
.breadcrumb span { opacity: .5; }

/* ---------- Filtres ---------- */
.filters {
    position: sticky; top: calc(var(--header-h) + 10px); z-index: 20;
    display: flex; gap: 12px; align-items: center; flex-wrap: wrap; padding: 10px; margin-bottom: 32px;
    border-radius: 20px; background: color-mix(in srgb, var(--bg-2) 80%, transparent); backdrop-filter: blur(14px);
    border: 1px solid var(--border);
}
.filters__chips { display: flex; gap: 6px; flex-wrap: wrap; flex: 1; }
.filter-chip {
    height: 36px; padding: 0 14px; border-radius: 999px; border: 1px solid transparent; background: transparent;
    color: var(--text-2); font-size: .88rem; font-weight: 500; transition: all .2s;
}
.filter-chip:hover { background: var(--surface-2); color: var(--text); }
.filter-chip.is-active { background: var(--text); color: var(--bg); }
.filter-chip .count { opacity: .55; margin-left: 4px; font-size: .78rem; }
.input, .select {
    height: 40px; padding: 0 14px; border-radius: 12px; border: 1px solid var(--border);
    background: var(--surface); color: var(--text); outline: none; transition: border-color .2s, box-shadow .2s;
}
.input:focus, .select:focus, textarea.input:focus { border-color: var(--accent); box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 15%, transparent); }
.select option { background: var(--surface-solid); }
.input-search { position: relative; }
.input-search .icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.input-search .input { padding-left: 38px; width: 240px; }
.empty-state { text-align: center; padding: 80px 20px; color: var(--muted); grid-column: 1 / -1; }
.empty-state .icon { width: 40px; height: 40px; margin: 0 auto 12px; opacity: .5; }

/* ---------- Article (tutoriel) ---------- */
.reading-progress { position: fixed; top: 0; left: 0; height: 3px; width: 0; z-index: 60; background: var(--grad); box-shadow: 0 0 12px var(--accent); }
.article-layout { display: grid; grid-template-columns: minmax(0, 1fr) 260px; gap: 64px; align-items: start; padding-bottom: 80px; }
.article-meta { display: flex; gap: 18px; flex-wrap: wrap; align-items: center; margin-top: 24px; color: var(--muted); font-size: .9rem; }
.article-meta > span { display: inline-flex; align-items: center; gap: 6px; }
.prose { font-size: 1.06rem; color: var(--text-2); max-width: 72ch; }
.prose > p:first-child { font-size: 1.2rem; color: var(--text); }
.prose h2 { font-size: 1.8rem; color: var(--text); margin: 2.2em 0 .7em; scroll-margin-top: calc(var(--header-h) + 24px); display: flex; align-items: center; gap: 12px; }
.prose h2::before { content: ''; width: 6px; height: 1.1em; border-radius: 3px; background: var(--grad); flex-shrink: 0; }
.prose h3 { font-size: 1.3rem; color: var(--text); margin: 1.8em 0 .6em; }
.prose a { color: var(--accent); text-decoration: underline; text-decoration-color: color-mix(in srgb, var(--accent) 40%, transparent); text-underline-offset: 3px; }
.prose strong { color: var(--text); font-weight: 600; }
.prose ul, .prose ol { padding-left: 1.3em; margin: 0 0 1.2em; }
.prose li { margin-bottom: .45em; }
.prose li::marker { color: var(--accent); }
.prose code { font-family: var(--font-mono); font-size: .86em; padding: 2px 7px; border-radius: 6px; background: var(--surface-2); border: 1px solid var(--border); color: var(--text); }
.prose pre {
    position: relative; margin: 1.5em 0; padding: 20px 22px; border-radius: 16px; overflow-x: auto;
    background: var(--code-bg); border: 1px solid var(--border); color: #c7d2e4; font-size: .86rem; line-height: 1.7;
}
.prose pre code { background: none; border: 0; padding: 0; color: inherit; font-size: inherit; }
.prose pre[data-lang]::before {
    content: attr(data-lang); position: absolute; top: 10px; right: 50px; font-family: var(--font-mono);
    font-size: .68rem; text-transform: uppercase; letter-spacing: .1em; color: #6b7a93;
}
.copy-code {
    position: absolute; top: 8px; right: 8px; width: 32px; height: 32px; border-radius: 8px; display: grid; place-items: center;
    background: rgba(255,255,255,.05); border: 1px solid rgba(255,255,255,.08); color: #9aa8bf; opacity: 0; transition: opacity .2s;
}
.prose pre:hover .copy-code { opacity: 1; }
.prose table { width: 100%; border-collapse: collapse; margin: 1.5em 0; font-size: .92rem; display: block; overflow-x: auto; }
.prose th, .prose td { padding: 10px 14px; border-bottom: 1px solid var(--border); text-align: left; }
.prose th { color: var(--text); font-weight: 600; background: var(--surface); }
.callout {
    display: flex; gap: 14px; padding: 18px 20px; border-radius: 16px; margin: 1.6em 0;
    background: color-mix(in srgb, var(--c) 8%, transparent); border: 1px solid color-mix(in srgb, var(--c) 25%, transparent);
    font-size: .97rem;
}
.callout .icon { color: var(--c); width: 22px; height: 22px; margin-top: 2px; }
.callout p:last-child { margin: 0; }
.callout .callout__link { display: inline-flex; align-items: center; gap: 6px; margin-top: 8px; font-weight: 600; }
.callout .callout__link .icon { width: 16px; height: 16px; margin: 0; }
.callout--tip { --c: var(--teal); } .callout--warn { --c: var(--amber); } .callout--info { --c: var(--blue); }
.steps { list-style: none; padding: 0 !important; counter-reset: s; }
.steps > li { position: relative; padding-left: 48px; margin-bottom: 18px; counter-increment: s; }
.steps > li::before {
    content: counter(s); position: absolute; left: 0; top: 0; width: 32px; height: 32px; border-radius: 10px;
    display: grid; place-items: center; font-family: var(--font-mono); font-size: .85rem; font-weight: 500;
    color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, transparent); border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent);
}
.figure-svg { margin: 1.8em 0; padding: 24px; border-radius: 20px; background: var(--surface); border: 1px solid var(--border); }
.figure-svg figcaption { font-size: .85rem; color: var(--muted); margin-top: 12px; text-align: center; }

.toc { position: sticky; top: calc(var(--header-h) + 32px); }
.toc__box { padding: 20px; border-radius: 20px; background: var(--surface); border: 1px solid var(--border); }
.toc h4 { font-family: var(--font-mono); font-size: .75rem; text-transform: uppercase; letter-spacing: .12em; color: var(--muted); margin-bottom: 12px; font-weight: 500; }
.toc ol { list-style: none; padding: 0; margin: 0; border-left: 1px solid var(--border); }
.toc a { display: block; padding: 6px 0 6px 14px; margin-left: -1px; border-left: 2px solid transparent; font-size: .88rem; color: var(--muted); transition: all .2s; }
.toc a:hover { color: var(--text); }
.toc a.is-active { color: var(--accent); border-left-color: var(--accent); }
.toc__tags { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 16px; }

.pager { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 64px; }
.pager a { padding: 22px 24px; }
.pager small { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: .8rem; margin-bottom: 6px; }
.pager strong { font-family: var(--font-display); font-size: 1.1rem; font-weight: 600; }
.pager .next { text-align: right; }
.pager .next small { justify-content: flex-end; }

/* ---------- Pages outils ---------- */
.tool-layout { display: grid; grid-template-columns: 380px minmax(0, 1fr); gap: 20px; padding-bottom: 80px; align-items: start; }
.tool-layout--full { grid-template-columns: 1fr; }
.panel { padding: 24px; border-radius: var(--radius-l); background: var(--surface); border: 1px solid var(--border); }
.panel + .panel { margin-top: 16px; }
.panel h3 { font-size: 1.05rem; margin-bottom: 16px; display: flex; align-items: center; gap: 10px; }
.panel h3 .icon { color: var(--accent); }
.field { display: grid; gap: 6px; margin-bottom: 14px; }
.field label { font-size: .8rem; font-weight: 500; color: var(--muted); }
.field .input, .field .select { width: 100%; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
textarea.input { height: auto; padding: 12px 14px; resize: vertical; font-family: var(--font-mono); font-size: .82rem; line-height: 1.6; }
.map-box {
    position: relative; height: 560px; border-radius: var(--radius-l); overflow: hidden;
    border: 1px solid var(--border); background: var(--bg-2);
}
/* Seule la carte (1er enfant) remplit la boîte : les barres flottantes gardent leur propre taille */
.map-box > div:first-child { position: absolute; inset: 0; }
.map-hint {
    position: absolute; left: 50%; top: 14px; transform: translateX(-50%); z-index: 500;
    padding: 8px 14px; border-radius: 999px; font-size: .82rem; white-space: nowrap;
    background: color-mix(in srgb, var(--bg) 80%, transparent); backdrop-filter: blur(10px); border: 1px solid var(--border);
    pointer-events: none;
}
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }
.seg { display: inline-flex; padding: 4px; gap: 4px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--border); width: 100%; }
.seg button { flex: 1; height: 34px; border-radius: 9px; border: 0; background: transparent; font-size: .86rem; font-weight: 500; color: var(--text-2); }
.seg button.is-active { background: var(--surface-solid); color: var(--text); box-shadow: 0 2px 8px rgba(0,0,0,.15); }
.result-list { display: grid; gap: 8px; }
.result {
    display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; align-items: center;
    padding: 12px 14px; border-radius: 14px; background: var(--surface); border: 1px solid var(--border);
}
.result small { font-size: .74rem; color: var(--muted); grid-column: 1; }
.result code { font-family: var(--font-mono); font-size: .88rem; color: var(--text); grid-column: 1; word-break: break-all; }
.result button { grid-row: 1 / span 2; grid-column: 2; }
.copy-btn {
    width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center;
    border: 1px solid var(--border); background: var(--surface-2); color: var(--muted); transition: all .2s;
}
.copy-btn:hover { color: var(--accent); border-color: var(--accent); }
.big-metric { font-family: var(--font-display); font-size: 2.6rem; font-weight: 600; letter-spacing: -.03em; line-height: 1.1; }
.big-metric small { font-size: 1rem; color: var(--muted); font-weight: 500; margin-left: 4px; }
.metric-label { font-size: .8rem; color: var(--muted); }
.metrics { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.data-table { width: 100%; border-collapse: collapse; font-size: .85rem; }
.data-table th, .data-table td { padding: 9px 12px; border-bottom: 1px solid var(--border); text-align: left; white-space: nowrap; }
.data-table th { position: sticky; top: 0; background: var(--surface-solid); font-weight: 600; font-size: .78rem; color: var(--muted); }
.data-table tr:hover td { background: var(--surface); }
.data-table tr.is-hl td { background: color-mix(in srgb, var(--accent) 12%, transparent); }
.table-wrap { max-height: 360px; overflow: auto; border-radius: 14px; border: 1px solid var(--border); }
.dropzone {
    display: block; border: 1.5px dashed var(--border-strong); border-radius: 16px; padding: 22px; text-align: center; color: var(--muted);
    font-size: .88rem; transition: all .2s; cursor: pointer;
}
.dropzone.is-over, .dropzone:hover { border-color: var(--accent); color: var(--text); background: color-mix(in srgb, var(--accent) 6%, transparent); }
.dropzone .icon { width: 28px; height: 28px; margin: 0 auto 8px; color: var(--accent); }
.error-msg { color: #ff6b6b; font-size: .85rem; margin-top: 8px; }
.file-formats { display: flex; flex-wrap: wrap; gap: 4px; justify-content: center; margin-top: 8px; }
.file-formats b { font-family: var(--font-mono); font-weight: 500; font-size: .72rem; padding: 2px 7px; border-radius: 6px; background: var(--surface-2); border: 1px solid var(--border); color: var(--text-2); }
.loader { display: flex; align-items: center; gap: 10px; margin-top: 12px; font-size: .86rem; color: var(--text-2); }
.loader span { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--border-strong); border-top-color: var(--accent); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.stat-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.stat-grid .result code { font-size: .82rem; }
.layer-list { display: grid; gap: 8px; }
.layer-item {
    display: grid; grid-template-columns: auto minmax(0, 1fr) auto auto; gap: 8px; align-items: center;
    padding: 10px; border-radius: 14px; background: var(--surface); border: 1px solid var(--border); transition: border-color .2s, background .2s;
}
.layer-item.is-sel { border-color: color-mix(in srgb, var(--accent) 55%, transparent); background: color-mix(in srgb, var(--accent) 6%, transparent); }
.layer-item__vis { display: grid; place-items: center; cursor: pointer; }
.layer-item__vis input { position: absolute; opacity: 0; pointer-events: none; }
.layer-item__vis i { width: 18px; height: 18px; border-radius: 6px; border: 2px solid rgba(255,255,255,.6); transition: opacity .2s; }
.layer-item__vis input:not(:checked) + i { opacity: .2; }
.layer-item__vis input:focus-visible + i { outline: 2px solid var(--accent); outline-offset: 2px; }
.layer-item__name { text-align: left; background: none; border: 0; padding: 0; min-width: 0; }
.layer-item__name strong { display: block; font-size: .9rem; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.layer-item__name small { display: block; font-size: .74rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.layer-item__crs { grid-column: 1 / -1; display: grid; gap: 6px; }
.layer-item__crs .select { width: 100%; height: 36px; font-size: .82rem; }
.check-list { display: grid; gap: 4px; max-height: 260px; overflow: auto; padding-right: 4px; }
.check-row { display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 10px; font-size: .86rem; cursor: pointer; }
.check-row:hover { background: var(--surface-2); }
.check-row input { accent-color: var(--accent); }
.check-row.is-off span, .check-row.is-off i, .check-row.is-off small { opacity: .4; }
.check-row.is-off span { text-decoration: line-through; }
.check-row i { width: 12px; height: 12px; border-radius: 4px; flex-shrink: 0; }
.check-row span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.check-row small { font-family: var(--font-mono); color: var(--muted); font-size: .74rem; }
.toggle-row { display: flex; align-items: center; gap: 10px; font-size: .88rem; color: var(--text-2); padding: 4px 0; cursor: pointer; }
.toggle-row input { accent-color: var(--accent); width: 16px; height: 16px; }
@media (max-width: 640px) { .stat-grid { grid-template-columns: 1fr; } }
.local-box {
    margin: 4px 0 14px; padding: 14px; border-radius: 14px; font-size: .86rem; color: var(--text-2);
    background: color-mix(in srgb, var(--amber) 8%, transparent); border: 1px solid color-mix(in srgb, var(--amber) 30%, transparent);
}
.local-box > p:first-child { margin: 0 0 10px; }
.step-num {
    width: 24px; height: 24px; border-radius: 8px; display: inline-grid; place-items: center; flex-shrink: 0;
    font-family: var(--font-mono); font-size: .78rem; color: var(--accent);
    background: color-mix(in srgb, var(--accent) 12%, transparent); border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent);
}
.dxf-label span {
    display: inline-block; transform: translate(0, -100%); white-space: nowrap; font: 600 11px/1.2 var(--font-sans);
    text-shadow: 0 0 3px #000, 0 0 6px #000;
}
.btn:disabled { opacity: .45; pointer-events: none; }
.track-stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 14px 18px; margin: 6px 0 18px; }
.track-stats__v { font-family: var(--font-display); font-size: 1.45rem; font-weight: 600; letter-spacing: -.02em; line-height: 1.2; }
.track-stats__v small { font-size: .8rem; color: var(--muted); font-weight: 500; margin-left: 3px; }
.profile { position: relative; border-radius: 14px; background: var(--bg-2); border: 1px solid var(--border); padding: 6px 4px 0; }
.profile svg { width: 100%; height: 220px; display: block; cursor: crosshair; touch-action: none; }
.profile__tip {
    position: absolute; top: 6px; transform: translateX(-50%); pointer-events: none; white-space: nowrap;
    padding: 4px 10px; border-radius: 999px; font-size: .78rem; background: var(--text); color: var(--bg);
}
.seg button { min-width: 0; padding: 0 4px; }

/* ---------- Croquis de terrain (MapLibre, outils sur la carte) ---------- */
.cq-stage {
    position: relative; height: clamp(560px, 82vh, 900px); border-radius: var(--radius-l); overflow: hidden;
    border: 1px solid var(--border); background: #e9edf2; margin-bottom: 20px; isolation: isolate;
}
.cq-stage:fullscreen { height: 100vh; border-radius: 0; border: 0; }
/* Barre des fiches (au-dessus de la carte) ; en plein écran, barre + carte occupent tout l'écran */
.cq-app:fullscreen { display: flex; flex-direction: column; background: var(--bg); padding: 8px; gap: 8px; }
.cq-app:fullscreen .cq-fichebar { margin: 0; }
.cq-app:fullscreen .cq-stage { flex: 1; height: auto; margin: 0; }
.cq-fichebar {
    display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; padding: 8px 10px; border-radius: 16px;
    background: var(--surface); border: 1px solid var(--border);
}
.cq-fichebar__label { font-family: var(--font-mono); font-size: .72rem; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); padding: 0 4px; }
.cq-fichebar .select { min-width: 220px; max-width: 360px; height: 38px; flex: 0 1 auto; }
.cq-fichebar .btn { height: 38px; }
.cq-fichebar .btn:disabled { opacity: .4; }
.cq-fichebar__spacer { flex: 1; }
.cq-fichebar__toggle { width: 38px; padding: 0; justify-content: center; font-size: .9rem; }
/* Barre réduite (tablette) : seulement le choix de la fiche, sur une ligne fine */
.cq-fichebar.is-collapsed { padding: 4px 6px; gap: 6px; flex-wrap: nowrap; margin-bottom: 6px; }
.cq-fichebar.is-collapsed > :not(.cq-fichebar__toggle):not(.select) { display: none; }
.cq-fichebar.is-collapsed .btn, .cq-fichebar.is-collapsed .select { height: 32px; }
.cq-fichebar.is-collapsed .cq-fichebar__toggle { width: 32px; }
.cq-fichebar.is-collapsed .select { min-width: 0; max-width: none; flex: 1 1 auto; }
.cq-fiche-pin { cursor: pointer; }
.cq-fiche-pin span {
    display: block; padding: 4px 10px; border-radius: 999px; white-space: nowrap; font: 600 12px/1.3 var(--font-sans);
    background: rgba(255,255,255,.92); color: #1a1f2b; border: 1px solid rgba(0,0,0,.15); box-shadow: 0 3px 10px rgba(0,0,0,.25);
}
.cq-fiche-pin.is-current span { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.cq-picking .maplibregl-canvas { cursor: crosshair !important; }
@media (max-width: 640px) { .cq-fichebar .select { min-width: 0; flex: 1 1 140px; } .cq-fichebar__spacer { display: none; } }
#cq-map { position: absolute; inset: 0; }
.cq-stage .maplibregl-canvas { outline: none; }
.cq-drawing .maplibregl-canvas-container, .cq-drawing .maplibregl-canvas { cursor: crosshair !important; }
.cq-erasing .maplibregl-canvas { cursor: not-allowed !important; }

/* Boutons ronds flottants */
/* Colonnes : jamais plus hautes que l'espace libre (barre du bas, échelle, attribution) ;
   défilement de secours sur les écrans très bas — plus aucun chevauchement possible */
.cq-col {
    position: absolute; z-index: 5; display: flex; flex-direction: column; gap: 4px; padding: 2px;
    overflow-y: auto; overflow-x: hidden; scrollbar-width: none; overscroll-behavior: contain;
}
.cq-col::-webkit-scrollbar { display: none; }
.cq-col--left { left: 10px; top: 56px; max-height: calc(100% - 56px - 76px); }
.cq-col--right { right: 10px; top: 10px; max-height: calc(100% - 10px - 76px); }
.cq-col__sep { flex: 0 0 auto; height: 1px; margin: 4px 6px; background: var(--border-strong); }
.cq-fab {
    position: relative; flex: 0 0 auto;
    width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; font-size: 1.05rem; line-height: 1;
    background: color-mix(in srgb, var(--surface-solid) 90%, transparent); color: var(--text);
    border: 1px solid var(--border); box-shadow: 0 4px 14px rgba(0,0,0,.18); backdrop-filter: blur(8px);
    transition: transform .15s, border-color .15s, background .15s;
}
.cq-fab:hover { border-color: var(--border-strong); }
.cq-fab.is-active, .cq-fab.is-open { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 22%, var(--surface-solid)); }
.cq-compass span { display: inline-block; transition: transform .2s; }
.cq-compass.is-rotated { border-color: var(--amber); }

/* Indicateur de mode */
.cq-mode {
    position: absolute; z-index: 5; left: 10px; top: 10px; max-width: calc(58% - 40px);
    padding: 8px 14px; border-radius: 999px; font-size: .82rem; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    background: color-mix(in srgb, var(--surface-solid) 90%, transparent); border: 1px solid var(--border); box-shadow: 0 4px 14px rgba(0,0,0,.15); backdrop-filter: blur(8px);
}
/* Commune du cadastre : en haut à droite, juste à gauche de la colonne de boutons */
.cq-chip {
    position: absolute; z-index: 5; right: 60px; top: 10px; max-width: calc(42% - 70px);
    padding: 8px 14px; border-radius: 999px; font-size: .8rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    background: color-mix(in srgb, var(--surface-solid) 90%, transparent); border: 1px solid var(--border);
    box-shadow: 0 4px 14px rgba(0,0,0,.15); backdrop-filter: blur(8px);
}
.cq-chip span { font-family: var(--font-mono); color: var(--accent); margin-left: 4px; }
/* Pastille GPS, sous celle de la commune (ou à sa place si le cadastre est masqué) */
.cq-chip--gps { top: 48px; font-family: var(--font-mono); font-size: .76rem; }
#cq-cadastre[hidden] + .cq-chip--gps { top: 10px; }
.cq-chip--gps.is-fix { border-color: #2fb673; color: #1f8f53; }
.cq-chip--gps.is-float { border-color: var(--amber); }

/* Panneaux */
.cq-pop {
    position: absolute; z-index: 6; width: min(270px, calc(100% - 90px)); max-height: calc(100% - 110px); overflow: auto;
    padding: 14px; border-radius: 16px; background: color-mix(in srgb, var(--surface-solid) 95%, transparent);
    border: 1px solid var(--border-strong); box-shadow: 0 18px 40px -10px rgba(0,0,0,.45); backdrop-filter: blur(12px);
    animation: pop .18s var(--ease);
}
.cq-pop--left { left: 60px; top: 56px; }
.cq-pop--right { right: 60px; top: 10px; }
.cq-badge {
    position: absolute; top: -3px; right: -3px; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 999px;
    font: 600 10px/16px var(--font-sans); color: var(--accent-ink); background: var(--accent); text-align: center;
}
.cq-photos { display: grid; gap: 10px; }
.cq-photo {
    position: relative; display: grid; place-items: center; height: 120px; border-radius: 12px; overflow: hidden;
    border: 1.5px dashed var(--border-strong); background: var(--surface); color: var(--text-2); font-size: .86rem; cursor: pointer;
}
.cq-photo:hover { border-color: var(--accent); color: var(--text); }
.cq-photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cq-photo__rm {
    position: absolute; top: 6px; right: 6px; width: 26px; height: 26px; border-radius: 8px; border: 0;
    background: rgba(0,0,0,.6); color: #fff; font-size: .8rem;
}
.cq-photo-caption { width: 100%; height: 34px; font-size: .82rem; margin-top: 4px; }
.cq-pop--wide { width: min(320px, calc(100% - 90px)); }
.cq-pop--dock { right: 12px; bottom: 74px; }
.cq-pop h4 { font-family: var(--font-mono); font-size: .68rem; font-weight: 500; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); margin: 14px 0 8px; }
.cq-pop h4:first-child { margin-top: 0; }
.cq-list { display: grid; gap: 4px; }
.cq-item {
    display: flex; align-items: center; gap: 8px; width: 100%; padding: 8px 10px; border-radius: 10px; text-align: left;
    background: var(--surface); border: 1px solid var(--border); font-size: .86rem; color: var(--text);
}
.cq-item:hover { border-color: var(--border-strong); }
.cq-item.is-active { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 16%, transparent); }
.cq-sym-ico svg { display: block; }
.cq-note { font-size: .76rem; color: var(--muted); margin: 8px 0 0; line-height: 1.45; }
.cq-field { display: grid; gap: 4px; font-size: .8rem; color: var(--text-2); margin: 10px 0; }
.cq-field input[type="range"] { accent-color: var(--accent); width: 100%; }
.cq-check { display: flex; align-items: center; gap: 8px; font-size: .84rem; color: var(--text-2); padding: 3px 0; cursor: pointer; }
.cq-check input { accent-color: var(--accent); }
.cq-list--radio { gap: 0; }
.cq-snaps { display: grid; grid-template-columns: 1fr 1fr; gap: 0 10px; margin-top: 4px; }
.cq-colors { display: flex; flex-wrap: wrap; gap: 6px; }
.cq-color { width: 28px; height: 28px; border-radius: 8px; border: 2px solid var(--border-strong); padding: 0; position: relative; overflow: hidden; }
.cq-color.is-active { outline: 2px solid var(--accent); outline-offset: 2px; }
.cq-color--pick { background: conic-gradient(red, yellow, lime, aqua, blue, magenta, red); cursor: pointer; }
.cq-color--pick input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.cq-refs { display: grid; gap: 8px; margin-top: 10px; }
.cq-ref-card { display: grid; gap: 6px; padding: 9px; border-radius: 12px; background: var(--surface); border: 1px solid var(--border); }
.cq-ref-top { display: flex; align-items: center; gap: 6px; }
.cq-ref-top input[type="checkbox"] { accent-color: var(--accent); flex: none; }
.cq-ref-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .84rem; font-weight: 600; }
.cq-ref-top .copy-btn { width: 26px; height: 26px; flex: none; }
.cq-pop input[type="color"] { width: 28px; height: 26px; padding: 1px; border: 1px solid var(--border-strong); border-radius: 7px; background: none; cursor: pointer; flex: none; }
.cq-pop input[type="color"]:disabled { opacity: .55; cursor: default; }
.cq-ref-field { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: 8px; font-size: .76rem; color: var(--text-2); }
.cq-ref-field .select { height: 30px; padding: 0 28px 0 8px; font-size: .78rem; }
.cq-ref-auto { font-size: .78rem; padding: 0; }
.cq-ref-auto small { color: var(--muted); }
.cq-ref-values { max-height: 150px; overflow-y: auto; display: grid; gap: 2px; padding: 4px 6px; border: 1px solid var(--border); border-radius: 8px; }
.cq-ref-val { display: flex; align-items: center; gap: 8px; font-size: .76rem; }
.cq-ref-val span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cq-ref-val input[type="color"] { width: 24px; height: 22px; }
.cq-ref-meta { font-size: .72rem; color: var(--muted); }
.cq-ref-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 6px; }
.cq-ref-grid label { display: grid; gap: 3px; font-size: .74rem; color: var(--text-2); }
.cq-ref-grid .input { height: 30px; padding: 0 8px; font-size: .8rem; }
.cq-ref-grid input[type="color"] { width: 100%; height: 30px; }
.cq-measured { display: grid; gap: 6px; }
.cq-measured__row { display: grid; grid-template-columns: 16px minmax(0, 1fr) auto; gap: 10px; align-items: center; font-size: .82rem; }
.cq-measured__row i { width: 16px; height: 16px; border-radius: 4px; border: 2px solid; }
.cq-measured__row b { display: block; font-weight: 600; }
.cq-measured__row small { color: var(--muted); font-size: .74rem; }
.cq-measured__row code { font-family: var(--font-mono); font-size: .78rem; }
.cq-measured__total { margin-top: 4px; padding-top: 8px; border-top: 1px solid var(--border); font-size: .8rem; color: var(--text-2); }

/* Barre du bas */
.cq-dock {
    position: absolute; z-index: 5; left: 50%; bottom: 14px; transform: translateX(-50%); max-width: calc(100% - 24px);
    display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: center; padding: 6px; border-radius: 18px;
    background: color-mix(in srgb, var(--surface-solid) 92%, transparent); border: 1px solid var(--border); box-shadow: 0 10px 30px -8px rgba(0,0,0,.4); backdrop-filter: blur(10px);
}
.cq-dock__main, .cq-dock__ctx, .cq-dock__opts { display: flex; align-items: center; gap: 4px; }
.cq-dock__ctx { padding-left: 8px; border-left: 1px solid var(--border); }
.cq-dock__opts { padding-left: 8px; border-left: 1px solid var(--border); }
.cq-dock__btn {
    height: 36px; padding: 0 12px; border-radius: 11px; border: 1px solid transparent; background: transparent;
    color: var(--text-2); font-size: .84rem; font-weight: 500; white-space: nowrap;
}
.cq-dock__btn:hover { background: var(--surface-2); color: var(--text); }
.cq-dock__btn.is-active, .cq-dock__btn.is-open { background: var(--text); color: var(--bg); }
.cq-dock__btn--ok { background: var(--accent); color: var(--accent-ink); }
.cq-dock .cq-check { padding: 0 6px; white-space: nowrap; }
/* Largeur = contenu (sinon, centrée par left: 50 %, la barre serait limitée à la moitié de la carte et passerait sur plusieurs lignes) */
.cq-dock { width: max-content; }
/* Tablette : icônes seules (le bandeau du haut indique déjà l'outil ; chaque bouton garde son infobulle) → une seule ligne */
@media (max-width: 1024px) {
    .cq-dock { flex-wrap: nowrap; gap: 6px; }
    .cq-dock .cq-dock__txt { display: none; }
    .cq-dock__btn { padding: 0 10px; }
    .cq-dock .cq-check { padding: 0 4px; gap: 4px; }
    .cq-dock__ctx, .cq-dock__opts { padding-left: 6px; }
}

/* Étiquettes, symboles, position */
.cq-label { pointer-events: none; }
.cq-label.is-interactive { pointer-events: auto; cursor: move; }
.cq-label span {
    display: block; white-space: nowrap; line-height: 1.1; font-family: var(--font-sans); font-weight: 600;
    -webkit-text-stroke: 3px #fff; paint-order: stroke fill;
}
.cq-cote:not(.cq-cote-libre) span { transform: translateY(-0.95em); }
/* Cote d'alignement : posée contre l'alignement, du côté opposé à la perpendiculaire (--sx = ±1) */
.cq-cote.cq-align-lbl span { transform: translateX(calc(var(--sx, -1) * (50% + 6px))); }
.cq-measure-label span { position: relative; color: #ff2d55; font-size: 14px; }
.cq-measure-label small { position: absolute; left: 50%; top: calc(100% + 1.1em); transform: translateX(-50%); font-size: 11px; font-weight: 500; white-space: nowrap; }
.cq-u1 span { text-decoration: underline; text-underline-offset: 3px; }
.cq-u2 span { text-decoration: underline double; text-underline-offset: 3px; }
.cq-symbol { position: relative; width: 22px; height: 22px; cursor: default; }
.cq-symbol svg { filter: drop-shadow(0 1px 1px rgba(0,0,0,.35)); display: block; }
.cq-symbol.is-interactive { cursor: text; }
.cq-symbol__num {
    position: absolute; left: 50%; top: calc(100% + 1px); transform: translateX(-50%); white-space: nowrap; line-height: 1;
    font-family: var(--font-sans); font-weight: 600; -webkit-text-stroke: 3px #fff; paint-order: stroke fill; pointer-events: none;
}
.cq-erasing .cq-symbol, .cq-erasing .cq-label.is-interactive { cursor: not-allowed; }
.cq-gps { width: 16px; height: 16px; border-radius: 50%; background: #1e88e5; border: 3px solid #fff; box-shadow: 0 0 0 6px rgba(30,136,229,.25); }
/* Échelle (gauche), barre Naviguer (centre) et attribution (droite) sur une même ligne en bas */
.cq-stage .maplibregl-ctrl-bottom-left,
.cq-stage .maplibregl-ctrl-bottom-right { bottom: 18px; }
.cq-dock { max-width: calc(100% - 300px); }
.cq-stage .maplibregl-ctrl-scale { background: rgba(255,255,255,.85); border-color: #333; color: #111; font-size: 11px; }

.cq-modal { position: absolute; inset: 0; z-index: 20; display: grid; place-items: center; background: rgba(2, 5, 12, .45); backdrop-filter: blur(3px); padding: 16px; }
.cq-modal__box { width: 100%; max-width: 380px; display: grid; gap: 12px; padding: 20px; border-radius: 18px; background: var(--surface-solid); border: 1px solid var(--border-strong); box-shadow: var(--shadow); }
.cq-modal__box label { font-weight: 600; font-size: .92rem; white-space: pre-line; line-height: 1.5; }
.cq-modal__box input { font-size: 1.1rem; font-family: var(--font-mono); }
.cq-modal__choices { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.cq-modal__choices .btn { height: 54px; font-size: 1rem; }
.cq-modal__choices--list { grid-template-columns: 1fr; gap: 8px; }
.cq-modal__choices--list .btn { justify-content: flex-start; height: 48px; padding: 0 16px; }
.cq-modal__choices .btn:disabled { opacity: .45; }
.cq-radio {
    display: flex; align-items: center; gap: 10px; height: 46px; padding: 0 14px; border-radius: 12px; cursor: pointer;
    border: 1px solid var(--border-strong); background: var(--surface); font-size: .98rem;
}
.cq-radio.is-on { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 14%, transparent); }
.cq-radio input { accent-color: var(--accent); width: 18px; height: 18px; }

/* Écran étroit : pas la place de tout aligner, l'échelle et l'attribution remontent au-dessus de la barre */
@media (max-width: 900px) {
    .cq-stage .maplibregl-ctrl-bottom-left,
    .cq-stage .maplibregl-ctrl-bottom-right { bottom: 66px; }
    .cq-dock { max-width: calc(100% - 24px); }
    .cq-col--left { max-height: calc(100% - 56px - 112px); }
    .cq-col--right { max-height: calc(100% - 10px - 112px); }
}
@media (max-width: 640px) {
    .cq-stage { height: 78vh; border-radius: 16px; }
    .cq-fab { width: 38px; height: 38px; border-radius: 11px; }
    .cq-col--left, .cq-col--right { max-height: calc(100% - 56px - 150px); } /* la barre du bas passe sur 2 lignes */
    .cq-dock { bottom: 8px; flex-wrap: wrap; }
    .cq-dock__btn { padding: 0 9px; }
    .cq-mode { font-size: .74rem; }
}

/* Réglages des étiquettes et colorisation par attribut */
.lab-colors { display: grid; grid-template-columns: auto auto minmax(0, 1fr); gap: 12px; align-items: end; }
.lab-colors .input { width: 100%; }
.color-swatch, .color-input {
    -webkit-appearance: none; appearance: none; border: 1px solid var(--border-strong); background: none; cursor: pointer; padding: 0;
}
.color-swatch { width: 52px; height: 40px; border-radius: 12px; }
.color-input { width: 26px; height: 26px; border-radius: 8px; flex-shrink: 0; }
.color-swatch::-webkit-color-swatch-wrapper, .color-input::-webkit-color-swatch-wrapper { padding: 3px; }
.color-swatch::-webkit-color-swatch, .color-input::-webkit-color-swatch { border: 0; border-radius: 6px; }
.color-swatch::-moz-color-swatch, .color-input::-moz-color-swatch { border: 0; border-radius: 6px; }
.color-values { display: grid; gap: 2px; max-height: 320px; overflow: auto; padding-right: 4px; }
.color-value-row { display: flex; align-items: center; gap: 10px; padding: 5px 8px; border-radius: 10px; font-size: .86rem; cursor: pointer; }
.color-value-row:hover { background: var(--surface-2); }
.color-value-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.color-value-row small { font-family: var(--font-mono); font-size: .74rem; color: var(--muted); }
.color-dot { width: 22px; height: 22px; border-radius: 7px; flex-shrink: 0; border: 1px solid var(--border); }
.color-empty { font-size: .85rem; color: var(--muted); padding: 6px 2px; }
.ramp-list { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.ramp { height: 24px; border-radius: 8px; border: 2px solid transparent; outline: 1px solid var(--border); }
.ramp.is-active { border-color: var(--text); }
.map-legend {
    max-width: 220px; max-height: 260px; overflow: auto; padding: 10px 12px; border-radius: 14px; font-size: .78rem; line-height: 1.4;
    background: color-mix(in srgb, var(--surface-solid) 90%, transparent); color: var(--text); border: 1px solid var(--border);
    backdrop-filter: blur(8px); box-shadow: var(--shadow);
}
.map-legend:empty { display: none; }
.map-legend strong { display: block; margin-bottom: 6px; font-family: var(--font-mono); font-size: .74rem; color: var(--muted); }
.map-legend div { display: flex; align-items: center; gap: 8px; padding: 1px 0; }
.map-legend i { width: 14px; height: 14px; border-radius: 4px; flex-shrink: 0; border: 1px solid rgba(255,255,255,.4); }
.map-legend span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.map-legend em { display: block; margin-top: 4px; color: var(--muted); }
/* En-tête cliquable : replie / déplie la légende (repliée d'office sur tablette) */
.map-legend__head {
    display: flex; align-items: center; justify-content: space-between; gap: 10px; width: 100%; padding: 0; margin-bottom: 6px;
    background: none; border: 0; color: inherit; cursor: pointer; text-align: left;
}
.map-legend__head strong { margin: 0; }
.map-legend__head b { font-size: .8rem; color: var(--muted); transition: transform .2s; }
.map-legend.is-folded { padding: 6px 10px; }
.map-legend.is-folded .map-legend__head { margin: 0; }
.map-legend.is-folded .map-legend__head b { transform: rotate(-90deg); }
.map-legend.is-folded > div, .map-legend.is-folded > em { display: none; }
@media (max-width: 1024px) { .map-legend { max-height: 40vh; max-width: 180px; } }

/* Outils MapLibre (visionneuse, KML / GPX, DXF) : une carte par couche (couleur, colorisation, étiquettes) */
.ml-cards { display: grid; gap: 10px; }
.ml-card {
    display: grid; gap: 10px; padding: 12px; border-radius: 14px; background: var(--surface); border: 1px solid var(--border);
    transition: border-color .2s, background .2s;
}
.ml-card.is-sel { border-color: color-mix(in srgb, var(--accent) 55%, transparent); background: color-mix(in srgb, var(--accent) 6%, transparent); }
.ml-card__top { display: grid; grid-template-columns: auto auto minmax(0, 1fr) auto auto; gap: 8px; align-items: center; }
.ml-card__top input[type="checkbox"] { accent-color: var(--accent); width: 16px; height: 16px; }
.ml-card .copy-btn { width: 30px; height: 30px; font-size: .8rem; }
.ml-field { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 10px; align-items: center; font-size: .8rem; color: var(--text-2); }
.ml-field .select { height: 36px; font-size: .82rem; }
.ml-seg button { height: 30px; font-size: .78rem; }
.ml-auto { font-size: .82rem; }
.ml-auto small { color: var(--muted); }
.ml-card .color-values { max-height: 220px; }
.ml-card .color-input:disabled { opacity: .55; cursor: default; }
.ml-cursor { width: 16px; height: 16px; border-radius: 50%; background: var(--accent); border: 3px solid #fff; box-shadow: 0 1px 6px rgba(0,0,0,.4); }

/* Visionneuse : carte pleine largeur, outils en boutons flottants (même principe que le croquis) */
.map-box.vw-stage { height: clamp(520px, 80vh, 880px); isolation: isolate; }
.vw-stage:fullscreen { height: 100vh; border-radius: 0; border: 0; }
/* Coins arrondis des cartes MapLibre : Safari (iPad, iPhone) ne découpe pas toujours le canevas WebGL
   avec « overflow: hidden » + « border-radius » ; clip-path force la découpe partout */
.map-box, .cq-stage { clip-path: inset(0 round var(--radius-l)); }
.map-box:fullscreen, .cq-stage:fullscreen, .cq-app:fullscreen .cq-stage { clip-path: none; }
.cq-app:fullscreen .cq-stage { border-radius: 14px; clip-path: inset(0 round 14px); }
@media (max-width: 640px) { .cq-stage { clip-path: inset(0 round 16px); } }
.vw-col { left: 10px; top: 10px; max-height: calc(100% - 60px); }
.vw-pop { left: 60px; top: 10px; width: min(320px, calc(100% - 130px)); max-height: calc(100% - 60px); }
.vw-pop--wide { width: min(400px, calc(100% - 130px)); }
.vw-pop .dropzone { padding: 16px 12px; font-size: .82rem; }
.vw-pop .field { margin-bottom: 12px; }
.vw-pop .seg button { font-size: .76rem; padding: 0 4px; }
.vw-status {
    position: absolute; z-index: 7; left: 50%; top: 10px; transform: translateX(-50%); max-width: calc(100% - 140px);
    padding: 8px 14px; border-radius: 14px; cursor: pointer; font-size: .84rem;
    background: color-mix(in srgb, var(--surface-solid) 94%, transparent); border: 1px solid var(--border-strong); box-shadow: var(--shadow);
}
.vw-status .loader, .vw-status .error-msg { margin: 0; }
.vw-dropzone {
    position: absolute; inset: 10px; z-index: 8; display: grid; place-items: center; pointer-events: none; border-radius: 18px;
    border: 2px dashed var(--accent); background: color-mix(in srgb, var(--accent) 14%, transparent); backdrop-filter: blur(2px);
}
.vw-dropzone div { display: flex; align-items: center; gap: 10px; padding: 12px 18px; border-radius: 14px; font-weight: 600; background: var(--surface-solid); box-shadow: var(--shadow); }
.vw-dropzone .icon { width: 22px; height: 22px; color: var(--accent); }
.vw-below { display: grid; grid-template-columns: minmax(0, 1fr); gap: 0; margin-top: 16px; }
/* Table attributaire : largeur bloquée sur celle de la carte, longues valeurs (JSON…) renvoyées à la ligne */
.vw-below .table-wrap { max-width: 100%; } /* (défilement horizontal interne seulement s'il y a trop de colonnes) */
#vw-table th, #vw-table td { white-space: normal; overflow-wrap: break-word; vertical-align: top; }
#vw-table td.is-long { overflow-wrap: anywhere; min-width: 14em; }

/* MapLibre harmonisé (cartes hors croquis) */
.map-box .maplibregl-map { font-family: var(--font-sans); }
.map-box .maplibregl-ctrl-group { background: var(--surface-solid); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow); overflow: hidden; }
.map-box .maplibregl-ctrl-group button { width: 34px; height: 34px; }
.map-box .maplibregl-ctrl-group button + button { border-top-color: var(--border); }
[data-theme="dark"] .map-box .maplibregl-ctrl-group button .maplibregl-ctrl-icon { filter: invert(1); }
.map-box .maplibregl-ctrl-scale { background: color-mix(in srgb, var(--bg) 70%, transparent); color: var(--text); border-color: var(--text-2); }
.map-box .map-badge { margin: 0 0 6px 10px; }
.map-box .map-legend { margin: 0 10px 6px 0; }
.ml-layers { position: relative; }
.ml-layers__btn {
    position: relative; width: 40px; height: 40px; border-radius: 13px; display: grid; place-items: center; color: var(--text);
    background: var(--surface-solid); border: 1px solid var(--border); box-shadow: var(--shadow);
}
.ml-layers__btn:hover { border-color: var(--accent); color: var(--accent); }
.ml-layers__pop {
    position: absolute; right: 0; top: 46px; z-index: 3; min-width: 260px; display: grid; gap: 2px; padding: 12px 14px;
    background: color-mix(in srgb, var(--surface-solid) 95%, transparent); color: var(--text); border: 1px solid var(--border);
    border-radius: 14px; box-shadow: var(--shadow); backdrop-filter: blur(10px); font-size: .82rem;
}
.ml-layers__pop strong { font-family: var(--font-mono); font-size: .68rem; font-weight: 500; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); margin: 6px 0 2px; }
.ml-layers__pop strong:first-child { margin-top: 0; }
.ml-layers__pop label { display: flex; align-items: center; gap: 8px; padding: 3px 0; cursor: pointer; }
.ml-layers__pop input { accent-color: var(--accent); margin: 0; }
.map-box .maplibregl-popup-content { background: var(--surface-solid); color: var(--text); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow); padding: 12px 14px; font-size: .82rem; }
.map-box .maplibregl-popup-close-button { color: var(--muted); font-size: 18px; padding: 0 6px; }
.map-box .maplibregl-popup-anchor-bottom .maplibregl-popup-tip { border-top-color: var(--surface-solid); }
.map-box .maplibregl-popup-anchor-top .maplibregl-popup-tip { border-bottom-color: var(--surface-solid); }
.map-box .maplibregl-popup-anchor-left .maplibregl-popup-tip { border-right-color: var(--surface-solid); }
.map-box .maplibregl-popup-anchor-right .maplibregl-popup-tip { border-left-color: var(--surface-solid); }
.map-box .maplibregl-ctrl-attrib { background: color-mix(in srgb, var(--surface-solid) 80%, transparent); color: var(--text-2); }
.map-box .maplibregl-ctrl-attrib a { color: var(--text-2); }

/* Démonstrations interactives des tutoriels (Leaflet et MapLibre) */
.demo-map { height: 520px; margin: 1.2em 0 .6em; }
/* La règle globale « img, svg, canvas { max-width: 100% } » casserait les tuiles et le dessin Leaflet */
.leaflet-container img, .leaflet-container svg, .leaflet-container canvas { max-width: none !important; max-height: none !important; }
.leaflet-container { font-family: var(--font-sans); }
/* Dans le texte d'un tutoriel (.prose) : on neutralise les styles de liens, tableaux et code sur la carte */
.prose .demo-map a { text-decoration: none; }
.prose .demo-map .leaflet-control a, .prose .demo-map .leaflet-bar a { color: #333; }
.prose .demo-map .leaflet-control-attribution a, .prose .demo-map .maplibregl-ctrl-attrib a { color: #0078a8; }
.prose .demo-map table { display: table; width: auto; margin: 4px 0 0; font-size: .8rem; }
.prose .demo-map th, .prose .demo-map td { padding: 1px 8px 1px 0; border: 0; }
.prose .demo-map strong { color: inherit; }
.prose .demo-map .leaflet-popup-content, .prose .demo-map .maplibregl-popup-content { color: #1a1f2b; font-size: .84rem; }
.demo-panel {
    position: absolute; z-index: 1000; left: 10px; top: 10px; display: grid; gap: 6px; max-width: min(300px, calc(100% - 80px));
    padding: 8px 10px; border-radius: 12px; font-size: .8rem; color: #1a1f2b; line-height: 1.35;
    background: rgba(255,255,255,.94); border: 1px solid rgba(0,0,0,.12); box-shadow: 0 6px 18px rgba(0,0,0,.2);
}
.demo-panel input[type="search"] { width: 100%; padding: 6px 8px; border-radius: 8px; border: 1px solid #c9ced8; font: inherit; color: #1a1f2b; background: #fff; }
.demo-panel label { display: flex; align-items: center; gap: 6px; cursor: pointer; }
.demo-panel input[type="checkbox"], .demo-panel input[type="radio"] { accent-color: #6d4cff; margin: 0; }
.demo-panel .demo-row { display: flex; flex-wrap: wrap; gap: 4px 10px; }
.demo-panel button { padding: 5px 9px; border-radius: 8px; border: 1px solid #c9ced8; background: #f4f6fa; font: inherit; color: #1a1f2b; cursor: pointer; }
.demo-panel button.is-on { background: #6d4cff; border-color: #6d4cff; color: #fff; }
.demo-panel small { color: #5b6372; }
.demo-out { font-family: var(--font-mono); font-size: .76rem; color: #6d4cff; }
.demo-coords { background: rgba(255,255,255,.88); padding: 2px 8px; border-radius: 6px; font: 12px var(--font-mono); color: #1a1f2b; }
.demo-legend { background: #fff; padding: 8px 12px; border-radius: 10px; font: 12px/1.6 var(--font-sans); color: #1a1f2b; box-shadow: 0 2px 8px rgba(0,0,0,.2); }
.demo-legend i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.demo-search input { width: 230px; padding: 6px 8px; border: 0; border-radius: 4px; font: 13px var(--font-sans); }
.demo-btn { display: grid !important; place-items: center; width: 34px; height: 34px; background: #fff; font-size: 17px; cursor: pointer; text-decoration: none; color: #1a1f2b !important; }
.demo-btn.is-on { background: #6d4cff; color: #fff !important; }
.demo-try { font-size: .9rem; }
.demo-panel--wide { max-width: min(360px, calc(100% - 80px)); max-height: calc(100% - 20px); overflow: auto; }
.demo-panel select, .demo-panel textarea { width: 100%; padding: 5px 7px; border-radius: 8px; border: 1px solid #c9ced8; font: inherit; color: #1a1f2b; background: #fff; }
.demo-panel select { width: auto; max-width: 100%; }
.demo-panel textarea { font: 12px/1.45 var(--font-mono); resize: vertical; }
.demo-panel button:disabled { opacity: .5; cursor: default; }
.demo-panel code { font: 11px var(--font-mono); word-break: break-all; }
.demo-table { width: 100%; border-collapse: collapse; font-size: .76rem; }
.demo-table th { text-align: left; font-weight: 500; color: #5b6372; padding: 3px 0 0; }
.demo-table td { font-family: var(--font-mono); padding: 0 0 3px; border-bottom: 1px solid #e6e8ee; }
.demo-table tr:has(td) th, .demo-table th + td { padding-right: 8px; }
.demo-legend-inline { display: grid; gap: 1px; font-size: .76rem; }
.demo-legend-inline i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; border: 1px solid rgba(0,0,0,.15); }
.demo-hist { width: 100%; height: auto; background: #f6f7fa; border-radius: 6px; }
.demo-py { margin: 0; padding: 6px 8px; border-radius: 8px; background: #1a1f2b; color: #e6edf3; font: 11px/1.5 var(--font-mono); white-space: pre-wrap; }
.prose .demo-code, .demo-code { max-height: 260px; overflow: auto; margin: 0 0 1em; font-size: .78rem; }
.prose .demo-attr { max-height: 240px; margin: 0 0 1em; }
.demo-box { margin: 1.2em 0; padding: 18px; border-radius: var(--radius-l); background: var(--surface); border: 1px solid var(--border); }
.demo-ogr__form { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 10px 16px; }
.demo-ogr__form label { display: grid; gap: 4px; font-size: .82rem; color: var(--text-2); }
.demo-ogr__form select, .demo-ogr__form input:not([type="checkbox"]) { padding: 7px 9px; border-radius: 9px; border: 1px solid var(--border-strong); background: var(--surface-solid); color: var(--text); font: inherit; }
.demo-ogr__form .demo-ogr__check { display: flex; align-items: center; gap: 8px; }
.demo-ogr__check input { accent-color: var(--accent); }
.demo-ogr__result { margin-top: 16px; }
.demo-ogr__cmd { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: 12px; background: #0d1220; }
.demo-ogr__cmd code { flex: 1; color: #2ee6c5 !important; background: none !important; border: 0 !important; padding: 0 !important; font: .86rem/1.6 var(--font-mono) !important; word-break: break-word; }
.demo-ogr__result ol { margin: 12px 0 0; font-size: .88rem; }
@media (max-width: 640px) { .demo-map { height: 440px; } .demo-panel { max-width: calc(100% - 70px); } .demo-search input { width: 160px; } }

/* Pastille et marqueurs des cartes */
[data-theme="dark"] .tile-dark { filter: invert(1) hue-rotate(180deg) brightness(.92) contrast(.88) saturate(.55); }
.map-badge {
    padding: 6px 12px; border-radius: 999px; font-size: .78rem; color: var(--text);
    background: color-mix(in srgb, var(--bg) 82%, transparent); backdrop-filter: blur(8px); border: 1px solid var(--border);
}
.map-badge:empty { display: none; }
.map-badge span { font-family: var(--font-mono); color: var(--accent); margin-left: 4px; }
.cl-marker { width: 22px; height: 22px; border-radius: 50%; background: var(--accent); border: 4px solid var(--bg); box-shadow: 0 0 0 2px var(--accent), 0 0 20px var(--accent); }
.vertex-marker { width: 12px; height: 12px; border-radius: 50%; background: var(--bg); border: 3px solid var(--violet); }

/* ---------- Ressources ---------- */
.res-group { margin-bottom: 64px; }
.res-group__head { display: flex; align-items: center; gap: 14px; margin-bottom: 22px; }
.res-group__head h2 { font-size: 1.6rem; margin: 0; }
.res-group__head span { font-family: var(--font-mono); font-size: .8rem; color: var(--muted); }
.res-group__head::after { content: ''; flex: 1; height: 1px; background: var(--border); }
.res-card { padding: 22px 24px; }
.res-card__top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; gap: 10px; }
.res-card h3 { font-size: 1.12rem; margin: 0; display: flex; align-items: center; gap: 8px; }
.res-card h3 .icon { width: 15px; height: 15px; color: var(--muted); transition: all .25s; }
.res-card:hover h3 .icon { color: var(--accent); transform: translate(2px, -2px); }
.res-card p { color: var(--text-2); font-size: .92rem; margin: 0; }
.res-card .url { font-family: var(--font-mono); font-size: .74rem; color: var(--muted); margin-top: 12px; display: block; }

/* ---------- Glossaire ---------- */
.alpha-nav { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 40px; }
.alpha-nav a, .alpha-nav span {
    width: 38px; height: 38px; display: grid; place-items: center; border-radius: 10px;
    font-family: var(--font-mono); font-size: .9rem; border: 1px solid var(--border); background: var(--surface);
}
.alpha-nav a:hover { border-color: var(--accent); color: var(--accent); }
.alpha-nav span { opacity: .3; }
.gloss-letter { display: grid; grid-template-columns: 80px 1fr; gap: 24px; padding: 32px 0; border-top: 1px solid var(--border); scroll-margin-top: calc(var(--header-h) + 90px); }
.gloss-letter > h2 { font-size: 3rem; margin: 0; line-height: 1; }
.gloss-terms { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
.gloss-term { padding: 20px 22px; border-radius: 18px; background: var(--surface); border: 1px solid var(--border); scroll-margin-top: calc(var(--header-h) + 90px); transition: border-color .3s, box-shadow .3s; }
.gloss-term h3 { font-size: 1.08rem; margin-bottom: 6px; }
.gloss-term p { font-size: .93rem; color: var(--text-2); margin: 0; }
.gloss-term:target { border-color: var(--accent); box-shadow: var(--glow); }

/* ---------- Palette de recherche ---------- */
.cmdk { position: fixed; inset: 0; z-index: 200; display: grid; place-items: start center; padding: 12vh 16px 16px; }
.cmdk[hidden] { display: none; }
.cmdk__backdrop { position: absolute; inset: 0; background: rgba(2, 5, 12, .6); backdrop-filter: blur(6px); animation: fade .2s; }
.cmdk__panel {
    position: relative; width: 100%; max-width: 620px; border-radius: 22px; overflow: hidden;
    background: var(--surface-solid); border: 1px solid var(--border-strong); box-shadow: 0 40px 100px -20px rgba(0,0,0,.6);
    animation: pop .25s var(--ease);
}
.cmdk__input { display: flex; align-items: center; gap: 12px; padding: 0 18px; border-bottom: 1px solid var(--border); }
.cmdk__input .icon { color: var(--muted); }
.cmdk__input input { flex: 1; height: 60px; border: 0; background: transparent; outline: none; font-size: 1.05rem; }
.cmdk__list { list-style: none; margin: 0; padding: 8px; max-height: 50vh; overflow: auto; }
.cmdk__list li a { display: flex; align-items: center; gap: 12px; padding: 11px 14px; border-radius: 12px; font-size: .95rem; }
.cmdk__list li a .kind { margin-left: auto; font-family: var(--font-mono); font-size: .7rem; color: var(--muted); padding: 2px 8px; border-radius: 6px; border: 1px solid var(--border); }
.cmdk__list li a .icon { color: var(--muted); }
.cmdk__list li.is-sel a { background: var(--surface-2); }
.cmdk__list li.is-sel a .icon { color: var(--accent); }
.cmdk__list mark { background: none; color: var(--accent); font-weight: 600; }
.cmdk__empty { padding: 30px; text-align: center; color: var(--muted); font-size: .9rem; }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translateY(-10px) scale(.98); } }

/* ---------- Toast ---------- */
.toast {
    position: fixed; bottom: 24px; left: 50%; z-index: 300; transform: translate(-50%, 30px); opacity: 0; pointer-events: none;
    padding: 12px 20px; border-radius: 999px; background: var(--text); color: var(--bg); font-size: .9rem; font-weight: 500;
    transition: all .35s var(--ease); box-shadow: var(--shadow);
}
.toast.is-on { transform: translate(-50%, 0); opacity: 1; }

/* ---------- Footer ---------- */
.site-footer { border-top: 1px solid var(--border); padding: 70px 0 30px; margin-top: 40px; background: var(--bg-2); }
.footer-grid { display: grid; grid-template-columns: 2fr 1fr 1fr 1fr; gap: 40px; }
.footer-grid h4 { font-family: var(--font-mono); font-size: .75rem; text-transform: uppercase; letter-spacing: .12em; color: var(--muted); font-weight: 500; margin-bottom: 16px; }
.footer-grid a:not(.brand) { display: block; color: var(--text-2); font-size: .92rem; padding: 4px 0; transition: color .2s; }
.footer-grid a:not(.brand):hover { color: var(--accent); }
.footer-brand p { color: var(--muted); font-size: .9rem; margin-top: 16px; max-width: 40ch; }
.footer-bottom { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-top: 56px; padding-top: 24px; border-top: 1px solid var(--border); font-size: .84rem; color: var(--muted); }

/* ---------- Apparition au scroll ---------- */
.reveal { opacity: 0; transform: translateY(24px); transition: opacity .8s var(--ease), transform .8s var(--ease), border-color .35s, box-shadow .35s, background .35s; }
.reveal.is-in { opacity: 1; transform: none; }
.reveal.is-in.card:hover { transform: translateY(-4px); }

/* ---------- Responsive ---------- */
@media (max-width: 1080px) {
    .search-trigger { min-width: 0; }
    .search-trigger span, .search-trigger kbd { display: none; }
    .search-trigger { width: 40px; padding: 0; justify-content: center; border-radius: 12px; }
    .grid-3 { grid-template-columns: repeat(2, 1fr); }
    .bento__a { grid-column: span 6; }
    .bento__b, .bento__c { grid-column: span 3; }
    .article-layout { grid-template-columns: 1fr; }
    .toc { display: none; }
    .tool-layout { grid-template-columns: 1fr; }
    .path { grid-template-columns: 1fr; gap: 0; }
    .path::before { left: 27px; right: auto; top: 20px; bottom: 20px; width: 2px; height: auto; background: linear-gradient(var(--teal), var(--violet), var(--lime)); }
    .path__step { display: grid; grid-template-columns: 56px 1fr; gap: 0 20px; text-align: left; padding: 0 0 26px; }
    .path__dot { margin: 0; grid-row: span 3; }
    .hud { display: none; }
}
@media (max-width: 860px) {
    .menu-btn { display: grid; }
    .main-nav {
        position: fixed; top: var(--header-h); left: 0; right: 0; margin: 0; padding: 16px;
        flex-direction: column; gap: 4px; background: var(--bg); border-bottom: 1px solid var(--border);
        transform: translateY(-10px); opacity: 0; pointer-events: none; transition: all .3s var(--ease);
    }
    .main-nav.is-open { transform: none; opacity: 1; pointer-events: auto; }
    .main-nav a { padding: 12px 16px; font-size: 1.05rem; }
    .main-nav a.is-active::after { display: none; }
    .footer-grid { grid-template-columns: 1fr 1fr; }
    .footer-brand { grid-column: 1 / -1; }
    .gloss-terms { grid-template-columns: 1fr; }
    .gloss-letter { grid-template-columns: 1fr; gap: 12px; }
}
@media (max-width: 640px) {
    .container { padding: 0 16px; }
    .section { padding: 72px 0; }
    .grid-3, .grid-2 { grid-template-columns: 1fr; }
    .bento { grid-template-columns: 1fr; }
    .bento > * { grid-column: auto !important; grid-row: auto !important; }
    .hero__inner { padding: 60px 16px 90px; }
    .hero__stats { gap: 28px; margin-top: 52px; }
    .stat strong { font-size: 1.7rem; }
    .filters { position: static; }
    .input-search, .input-search .input { width: 100%; }
    .pager { grid-template-columns: 1fr; }
    .map-box { height: 420px; }
    .field-row, .metrics { grid-template-columns: 1fr 1fr; }
    .footer-grid { grid-template-columns: 1fr; }
    .btn { height: 46px; padding: 0 18px; }
}

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