/* Emoji Codex — papier, encre, sceaux. Typographie froide (système), couleur portée par les signes. */

@font-face { font-family: "Codex Archivo"; src: url(fonts/archivo-codex.woff2) format("woff2"); font-weight: 800; font-display: optional; }
@font-face { font-family: "Codex G1"; src: url(fonts/noto-sans-symbols.woff2) format("woff2"); font-display: swap;
  unicode-range: U+A7, U+B6, U+2020-2021, U+203B, U+2042, U+204B, U+2205, U+221E, U+2234-2235, U+2237, U+2248, U+2261, U+2295, U+2297, U+2299-229B, U+22B9, U+22C6, U+2318, U+2325, U+232C, U+23E3, U+25A0-25A3, U+25B2-25B3, U+25B7, U+25BC-25BD, U+25C1, U+25C6-25D3, U+25EC, U+25EF, U+2605-2606, U+2609-260D, U+2613, U+2619, U+261E, U+2624-2625, U+2627-2629, U+262C-262D, U+263C-263F, U+2641, U+2643-2647, U+2698, U+269A, U+269D, U+26B2-26BC, U+26E2, U+26E4, U+271E, U+2720, U+2722-2727, U+2729-2732, U+2735-2743, U+2745-2746, U+2748-274B, U+2756, U+2761, U+2766-2767, U+27C1, U+29BF, U+29EB, U+2B1A, U+2B1F-2B24, U+2B51-2B52, U+2E38, U+1F700-1F77F; }
@font-face { font-family: "Codex G2"; src: url(fonts/noto-sans-symbols-2.woff2) format("woff2"); font-display: swap;
  unicode-range: U+A7, U+B6, U+2020-2021, U+203B, U+2042, U+204B, U+2205, U+221E, U+2234-2235, U+2237, U+2248, U+2261, U+2295, U+2297, U+2299-229B, U+22B9, U+22C6, U+2318, U+2325, U+232C, U+23E3, U+25A0-25A3, U+25B2-25B3, U+25B7, U+25BC-25BD, U+25C1, U+25C6-25D3, U+25EC, U+25EF, U+2605-2606, U+2609-260D, U+2613, U+2619, U+261E, U+2624-2625, U+2627-2629, U+262C-262D, U+263C-263F, U+2641, U+2643-2647, U+2698, U+269A, U+269D, U+26B2-26BC, U+26E2, U+26E4, U+271E, U+2720, U+2722-2727, U+2729-2732, U+2735-2743, U+2745-2746, U+2748-274B, U+2756, U+2761, U+2766-2767, U+27C1, U+29BF, U+29EB, U+2B1A, U+2B1F-2B24, U+2B51-2B52, U+2E38, U+1F700-1F77F; }
@font-face { font-family: "Codex G3"; src: url(fonts/noto-sans-math.woff2) format("woff2"); font-display: swap;
  unicode-range: U+2205, U+221E, U+2234-2235, U+2237, U+2248, U+2261, U+2295, U+2297, U+2299-229B, U+22B9, U+22C6, U+27C1, U+29BF, U+29EB; }

:root {
  --paper: #FAF6EE;
  --paper-2: #F2ECE1;
  --paper-3: #E9E1D3;
  --ink: #2D1B33;
  --ink-2: #6B6070;
  --ink-3: #8C8290;
  --rule: #E6DED3;
  --primary-bg: #2D1B33;
  --primary-fg: #FAF6EE;
  --warn: #8B1538;
  --warn-bg: #F7E6EA;
  --word-disc: #EFE8DC;
  --seg-on: #FFFDF8;
  --backdrop: rgba(23, 18, 27, .34);
  --shadow: 0 1px 2px rgba(45, 27, 51, .06), 0 10px 30px rgba(45, 27, 51, .10);

  --ink-venitien: #8B1538;
  --ink-sauge: #4F6F55;
  --ink-rouille: #9A5B2E;
  --ink-prune: #5B2A6E;
  --ink-vertdeau: #2F6F6A;
  --ink-bleue: #2B4C7E;
  --ink-neutre: #6B6070;

  --ease: cubic-bezier(.2, .8, .2, 1);
  --font-ui: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", system-ui, Roboto, "Helvetica Neue", Arial, "Codex G1", "Codex G2", "Codex G3", sans-serif;
  --font-emoji: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", "Codex G1", "Codex G2", "Codex G3", -apple-system, system-ui, sans-serif;
  --font-glyph: "Codex G1", "Codex G2", "Codex G3", "Apple Symbols", "Segoe UI Symbol", -apple-system, system-ui, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  color-scheme: light;
}

:root[data-theme="dark"] {
  --paper: #17121B; --paper-2: #211A26; --paper-3: #2B2331; --ink: #EDE6DA; --ink-2: #A69BAA; --ink-3: #7F7584; --rule: #332A39;
  --primary-bg: #E6C08A; --primary-fg: #17121B; --warn: #E07A8F; --warn-bg: #3A1C27; --word-disc: #2D2533; --seg-on: #3A3141; --backdrop: rgba(0, 0, 0, .5);
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 12px 32px rgba(0, 0, 0, .35);
  --ink-venitien: #E07A8F; --ink-sauge: #8FB896; --ink-rouille: #D4A574; --ink-prune: #C9A2D6; --ink-vertdeau: #7CC4BC; --ink-bleue: #8FB0E0; --ink-neutre: #A69BAA;
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #17121B; --paper-2: #211A26; --paper-3: #2B2331; --ink: #EDE6DA; --ink-2: #A69BAA; --ink-3: #7F7584; --rule: #332A39;
    --primary-bg: #E6C08A; --primary-fg: #17121B; --warn: #E07A8F; --warn-bg: #3A1C27; --word-disc: #2D2533; --seg-on: #3A3141; --backdrop: rgba(0, 0, 0, .5);
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 12px 32px rgba(0, 0, 0, .35);
    --ink-venitien: #E07A8F; --ink-sauge: #8FB896; --ink-rouille: #D4A574; --ink-prune: #C9A2D6; --ink-vertdeau: #7CC4BC; --ink-bleue: #8FB0E0; --ink-neutre: #A69BAA;
    color-scheme: dark;
  }
}

[data-ink="venitien"] { --c: var(--ink-venitien); }
[data-ink="sauge"] { --c: var(--ink-sauge); }
[data-ink="rouille"] { --c: var(--ink-rouille); }
[data-ink="prune"] { --c: var(--ink-prune); }
[data-ink="vertdeau"] { --c: var(--ink-vertdeau); }
[data-ink="bleue"] { --c: var(--ink-bleue); }
[data-ink="neutre"] { --c: var(--ink-neutre); }

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; background: var(--paper); }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 17px/1.4 var(--font-ui);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
button:disabled { cursor: default; opacity: .45; }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; border-radius: 8px; }
[hidden] { display: none !important; }
b { font-weight: 700; }
code { font-family: var(--font-mono); font-size: .88em; }
.warn-text { color: var(--warn); }

/* ─── Squelette de démarrage (sans JS) ─────────────────────────────────── */

#boot {
  position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; background: var(--paper);
  transition: opacity .2s var(--ease), visibility 0s .2s;
}
html[data-boot="ok"] #boot { opacity: 0; visibility: hidden; pointer-events: none; }
.boot__mark { display: flex; align-items: center; gap: 12px; font: 800 30px/1 "Codex Archivo", var(--font-ui); letter-spacing: -.02em; }
.boot__seal {
  width: 36px; height: 36px; border-radius: 50%;
  background: color-mix(in srgb, var(--ink-venitien) 9%, var(--paper));
  box-shadow: inset 0 0 0 1.5px var(--ink-venitien), inset 0 0 0 4px color-mix(in srgb, var(--ink-venitien) 9%, var(--paper)), inset 0 0 0 4.75px color-mix(in srgb, var(--ink-venitien) 45%, var(--paper));
}
.boot__slow, .boot__fail { position: absolute; bottom: 22%; left: 0; right: 0; margin: 0; text-align: center; color: var(--ink-2); font-size: 15px; opacity: 0; }
.boot__slow { animation: appear .3s ease 2s forwards, vanish .2s ease 8s forwards; }
.boot__fail { animation: appear .3s ease 8s forwards; }
.boot__fail a { color: var(--ink); }
@keyframes appear { to { opacity: 1; } }
@keyframes vanish { to { opacity: 0; } }

/* ─── Écran ────────────────────────────────────────────────────────────── */

.codex { max-width: 720px; margin: 0 auto; padding: 0 16px calc(env(safe-area-inset-bottom) + 40px); min-height: 100vh; }
.top {
  position: sticky; top: 0; z-index: 5;
  margin: 0 -16px; padding: env(safe-area-inset-top) 16px 8px;
  background: color-mix(in srgb, var(--paper) 90%, transparent);
  -webkit-backdrop-filter: saturate(1.4) blur(14px); backdrop-filter: saturate(1.4) blur(14px);
}
.top__row { display: flex; align-items: center; justify-content: space-between; height: 56px; transition: margin .28s var(--ease), opacity .2s var(--ease); }
.top.is-folded .top__row { margin-top: -56px; opacity: 0; pointer-events: none; }
.top__actions { display: flex; gap: 2px; margin-right: -10px; }
.wordmark { display: flex; align-items: center; gap: 10px; margin: 0; font: 800 27px/1 "Codex Archivo", var(--font-ui); letter-spacing: -.025em; }
.mark { display: block; flex: none; }
.mark__disc { fill: color-mix(in srgb, var(--ink-venitien) 9%, var(--paper)); }
.mark__ring { stroke: var(--ink-venitien); }
.mark__ring--in { stroke-opacity: .45; }
.mark__ink { fill: var(--ink-venitien); }

.bar {
  display: flex; align-items: center; gap: 8px; height: 46px; padding: 0 6px 0 14px;
  background: var(--paper-2); border-radius: 14px; color: var(--ink-2);
}
.bar input { flex: 1; min-width: 0; height: 100%; border: 0; background: none; outline: none; font-size: 17px; color: var(--ink); }
.bar input::placeholder { color: var(--ink-3); }
.bar input::-webkit-search-cancel-button { display: none; }

.banners { margin: 0; }
.banner { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: calc(env(safe-area-inset-top) + 10px) 16px 10px; background: var(--paper-2); border-bottom: 1px solid var(--rule); font-size: 14.5px; }
.banner + .banner { padding-top: 10px; }
.banner--warn { background: var(--warn-bg); }

/* ─── Registre ─────────────────────────────────────────────────────────── */

.worlds { display: flex; gap: 8px; overflow-x: auto; margin: 4px -16px 0; padding: 6px 16px 8px; scrollbar-width: none; }
.worlds::-webkit-scrollbar, .chips--scroll::-webkit-scrollbar, .scale::-webkit-scrollbar { display: none; }
.worlds__sep { flex: none; width: 1px; margin: 6px 2px; background: var(--rule); }

.part-title { display: flex; align-items: baseline; gap: 8px; margin: 30px 0 4px; font-size: 13px; font-weight: 650; letter-spacing: .14em; text-transform: uppercase; color: var(--ink-2); }
.part-title__num { font-weight: 800; color: var(--ink); letter-spacing: 0; }
.world__name { display: flex; align-items: center; gap: 9px; margin: 24px 0 2px; font-size: 21px; font-weight: 780; letter-spacing: -.01em; }
.world__dot { flex: none; width: 10px; height: 10px; border-radius: 50%; background: var(--c); }

.chapter { margin: 12px 0 20px; }
.chapter__head { display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--rule); }
.chapter__title { flex: 1; display: flex; align-items: baseline; gap: 10px; padding: 10px 0 8px; border: 0; background: none; text-align: left; }
.chapter__name { font-size: 12.5px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; }
.chapter__count { font-size: 12.5px; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.chapter.is-collapsed .chapter__name::after { content: " ›"; color: var(--ink-3); }
.chapter__warn { margin: 8px 0 0; font-size: 13.5px; color: var(--warn); }
.chapter__old { margin: 6px 0 0; padding: 6px 0; border: 0; background: none; color: var(--ink-2); font-size: 13.5px; text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--rule); }

.grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 4px; margin: 0; padding: 10px 0 0; list-style: none; }
.grid--old { opacity: .55; }
.cell { min-width: 0; }
.cell__btn {
  width: 100%; min-height: 92px; display: flex; flex-direction: column; align-items: center; gap: 7px;
  padding: 8px 2px 8px; border: 0; border-radius: 14px; background: none; color: inherit;
  -webkit-touch-callout: none; user-select: none; -webkit-user-select: none; transition: background .15s var(--ease), transform .12s var(--ease);
}
.cell__btn:active { background: var(--paper-2); transform: scale(.97); }
.cell__name { max-width: 100%; font-size: 12.5px; line-height: 1.22; text-align: center; overflow-wrap: anywhere; hyphens: auto; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.cell.is-warn .seal::after { content: ""; position: absolute; right: -1px; bottom: -1px; width: 11px; height: 11px; border-radius: 50%; background: var(--warn); box-shadow: 0 0 0 2px var(--paper); }
.cell.is-old { opacity: .55; }
.cell--add { opacity: .7; }
.cell--add .cell__name { color: var(--ink-3); }
.seal--add { color: var(--ink-3); background: none !important; }
.seal--add::before { border: 1.5px dashed var(--rule); }

.scale { display: flex; margin: 0 -16px; padding: 12px 16px 2px; list-style: none; overflow-x: auto; scroll-snap-type: x proximity; scrollbar-width: none; }
.cell--station { position: relative; flex: 0 0 86px; scroll-snap-align: start; }
.cell--station::before { content: ""; position: absolute; top: 30px; left: 0; right: 0; height: 1.5px; background: color-mix(in srgb, var(--c) 35%, transparent); }
.cell--station:first-child::before { left: 50%; }
.cell--station:last-child::before { right: 50%; }
.cell--station:only-child::before { display: none; }
.cell--station .seal { z-index: 1; }

html[data-planche="1"] .grid { grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 2px; }
html[data-planche="1"] .cell__name { display: none; }
html[data-planche="1"] .cell__btn { min-height: 0; padding: 4px 0; }
html[data-planche="1"] .grid .seal--44 { --s: 36px; }
html[data-planche="1"] .cell--add { display: none; }

.words { margin-top: 8px; }
.dict { margin: 6px 0 0; padding: 0; list-style: none; }
.dict__btn {
  width: 100%; display: flex; align-items: center; gap: 14px; padding: 9px 0; border: 0; border-bottom: 1px solid var(--rule);
  background: none; color: inherit; text-align: left; -webkit-touch-callout: none; user-select: none; -webkit-user-select: none;
}
.dict__btn:active { background: var(--paper-2); }
.dict__text { display: flex; flex-direction: column; min-width: 0; }
.dict__text small { color: var(--ink-2); font-size: 13.5px; }
.gloss { font-style: italic; font-size: 17px; }
.empty { margin: 14px 0; color: var(--ink-2); font-size: 15px; line-height: 1.5; }
.add-row { display: inline-flex; align-items: center; gap: 8px; margin: 10px 0 0; padding: 10px 0; border: 0; background: none; color: var(--ink-2); font-size: 15px; }
.add-row--big { display: flex; width: 100%; margin-top: 18px; padding: 16px; border: 1px dashed var(--rule); border-radius: 16px; color: var(--ink); }

.inbox-line {
  width: 100%; display: flex; align-items: center; gap: 12px; margin: 12px 0 0; padding: 12px 12px 12px 16px;
  border: 0; border-radius: 16px; background: var(--paper-2); color: inherit; text-align: left;
}
.inbox-line__label { flex: none; font-weight: 700; font-size: 15px; }
.inbox-line__signs { flex: 1; min-width: 0; font-family: var(--font-emoji); font-size: 21px; letter-spacing: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.colophon { margin: 48px 0 0; padding: 16px 0 0; border-top: 1px solid var(--rule); text-align: center; color: var(--ink-2); font-size: 13px; }
.colophon__line { margin: 0 0 6px; font-variant-numeric: oldstyle-nums proportional-nums; }
.colophon__links { display: flex; justify-content: center; flex-wrap: wrap; gap: 4px; margin: 0; }
.link { padding: 6px 8px; border: 0; background: none; color: var(--ink); font-size: 14px; text-decoration: underline; text-decoration-color: var(--rule); text-underline-offset: 3px; }

/* ─── Sceau ────────────────────────────────────────────────────────────── */

.seal {
  --c: var(--ink-venitien);
  --disc: color-mix(in srgb, var(--c) 9%, var(--paper));
  position: relative; display: inline-grid; place-items: center; flex: none;
  width: var(--s); height: var(--s); border-radius: 50%;
  background: var(--disc);
  font: 400 calc(var(--s) * .54) / 1 var(--font-emoji);
}
.seal[data-ink="venitien"] { --c: var(--ink-venitien); } .seal[data-ink="sauge"] { --c: var(--ink-sauge); } .seal[data-ink="rouille"] { --c: var(--ink-rouille); }
.seal[data-ink="prune"] { --c: var(--ink-prune); } .seal[data-ink="vertdeau"] { --c: var(--ink-vertdeau); } .seal[data-ink="bleue"] { --c: var(--ink-bleue); } .seal[data-ink="neutre"] { --c: var(--ink-neutre); }
.seal--32 { --s: 32px; } .seal--44 { --s: 44px; } .seal--64 { --s: 64px; } .seal--96 { --s: 96px; } .seal--136 { --s: 136px; }
.seal::before { content: ""; position: absolute; inset: 0; border-radius: 50%; pointer-events: none; }
.seal--code::before { box-shadow: inset 0 0 0 1.5px var(--c), inset 0 0 0 calc(var(--s) * .075) var(--disc), inset 0 0 0 calc(var(--s) * .075 + .75px) color-mix(in srgb, var(--c) 42%, var(--disc)); }
.seal--wait { background: none; }
.seal--wait::before { border: 1.5px dashed color-mix(in srgb, var(--c) 62%, transparent); }
.seal--word { background: var(--word-disc); }
.seal__g { position: relative; display: block; white-space: nowrap; line-height: 1; }
.seal--glyph .seal__g { font-family: var(--font-glyph); color: var(--c); font-size: .92em; }
.seal--n2 .seal__g { font-size: .66em; letter-spacing: -.04em; }
.seal--n3 .seal__g { font-size: .5em; letter-spacing: -.05em; }
.seal__q { position: relative; font: 650 calc(var(--s) * .4) / 1 var(--font-ui); color: color-mix(in srgb, var(--c) 70%, transparent); }
.seal__sup { position: absolute; top: -3px; right: -7px; font: 700 12px/1 var(--font-ui); color: var(--c); }
.seal--136 .seal__sup { top: 4px; right: -4px; font-size: 20px; }
.seal.is-hidden .seal__g { visibility: hidden; }
.seal.is-stamp { animation: stamp .44s var(--ease) both; }
@keyframes stamp {
  0% { transform: scale(1.32) rotate(-7deg); opacity: 0; }
  55% { transform: scale(.95) rotate(1deg); opacity: 1; }
  100% { transform: none; opacity: 1; }
}
.codex.is-stamping .cell .seal { animation: stamp .46s var(--ease) both; animation-delay: calc(min(var(--i, 0), 24) * 26ms); }

/* ─── Résultats, lecture ───────────────────────────────────────────────── */

.results { padding: 4px 0 20px; }
.results__none { margin: 16px 0 4px; color: var(--ink-2); }
.section-label { margin: 22px 0 6px; font-size: 12px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; color: var(--ink-2); }
.rows { margin: 0; padding: 0; list-style: none; }
.row { display: flex; align-items: center; border-bottom: 1px solid var(--rule); }
.row__main {
  flex: 1; min-width: 0; min-height: 58px; display: flex; align-items: center; gap: 12px; padding: 7px 0;
  border: 0; background: none; color: inherit; text-align: left; -webkit-touch-callout: none; user-select: none; -webkit-user-select: none;
}
.row__main--static { cursor: default; }
.row__text { display: flex; flex-direction: column; min-width: 0; }
.row__text small { color: var(--ink-2); font-size: 13px; }
.head { font-weight: 650; }
.add-line {
  width: 100%; display: flex; align-items: center; gap: 12px; margin: 12px 0; padding: 10px 12px;
  border: 1px dashed var(--rule); border-radius: 16px; background: none; color: inherit; text-align: left;
}
.add-line small { display: block; color: var(--ink-2); font-size: 13px; }
.add-line__signs { font-family: var(--font-emoji); font-size: 22px; letter-spacing: 3px; }
.add-line__go { margin-left: auto; font-weight: 700; white-space: nowrap; display: inline-flex; }

.sign-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(50px, 1fr)); gap: 2px; margin: 4px 0; }
.sign-grid--picker { content-visibility: auto; contain-intrinsic-size: 400px; }
.sign-btn { position: relative; height: 52px; border: 0; border-radius: 12px; background: none; }
.sign-btn:active, .sign-btn.is-current { background: var(--paper-2); }
.sign-btn__g { font: 30px/1 var(--font-emoji); }
.sign-btn__g.is-glyph { font-family: var(--font-glyph); font-size: 27px; color: var(--ink); }
.dot { position: absolute; top: 6px; right: 6px; width: 8px; height: 8px; border-radius: 50%; background: var(--c); box-shadow: 0 0 0 2px var(--paper); }

.lecture { margin: 10px 0 0; padding: 14px 16px; background: var(--paper-2); border-radius: 16px; }
.lecture .section-label { margin-top: 0; }
.lecture__text { margin: 0; font-size: 19px; line-height: 2.5; overflow-wrap: anywhere; }
.gloss-sign { display: inline-flex; flex-direction: column; align-items: center; vertical-align: -.55em; margin: 0 3px; padding: 0; border: 0; background: none; line-height: 1; }
.gloss-sign__g { font: 25px/1 var(--font-emoji); }
.gloss-sign__t { margin-top: 3px; max-width: 110px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font: 700 9.5px/1.1 var(--font-ui); letter-spacing: .08em; text-transform: uppercase; color: var(--ink-2); }
.gloss-sign.is-old .gloss-sign__t { font-style: italic; }
.gloss-sign.is-unknown .gloss-sign__g { text-decoration: underline dotted var(--ink-3); text-underline-offset: 4px; }

/* ─── Pour dire… ───────────────────────────────────────────────────────── */

.pourdire { margin: 14px 0 4px; padding: 16px 16px 8px; border-radius: 20px; background: var(--paper-2); }
.pourdire--sheet { background: none; padding: 4px 0; }
.pourdire__head { display: flex; justify-content: space-between; align-items: baseline; }
.pourdire__head .section-label { margin: 0; }
.pourdire__progress { font-size: 12.5px; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.pourdire__say { margin: 8px 0 2px; font-size: 23px; line-height: 1.2; font-weight: 750; letter-spacing: -.012em; }
.pourdire__hint { margin: 0; color: var(--ink-2); font-size: 14.5px; }
.pourdire__cands { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin: 14px 0 6px; }
.pourdire:not(.pourdire--sheet) .pourdire__cands { grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 6px; margin: 12px 0 4px; }
.pourdire:not(.pourdire--sheet) .cand { height: 56px; border-radius: 14px; }
.pourdire:not(.pourdire--sheet) .cand__g { font-size: 29px; }
.cand.has-al::after { content: ""; position: absolute; top: 6px; right: 6px; width: 6px; height: 6px; border-radius: 50%; background: var(--ink-3); }
.pourdire__foot { display: flex; flex-wrap: wrap; justify-content: space-between; margin: 0 -8px; }
.pourdire__links { display: flex; flex-wrap: wrap; justify-content: center; gap: 0 2px; margin: 2px -8px 0; }
.pourdire__links .link { font-size: 14px; color: var(--ink-2); }
.cand {
  position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  height: 78px; border: 1px solid var(--rule); border-radius: 16px; background: var(--paper); transition: transform .12s var(--ease), border-color .15s;
}
.cand:active { transform: scale(.96); }
.cand__g { font: 38px/1 var(--font-emoji); }
.cand__al { max-width: 92%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 10.5px; color: var(--ink-2); }
.cand.is-picked { border-color: var(--ink); animation: stamp .44s var(--ease); }
.pourdire.is-chosen .cand:not(.is-picked) { opacity: .4; transition: opacity .2s; }
.intent-list { margin: 20px 0 0; padding: 0; list-style: none; }
.intent-row { width: 100%; display: flex; justify-content: space-between; gap: 12px; padding: 12px 0; border: 0; border-bottom: 1px solid var(--rule); background: none; text-align: left; }
.intent-row.is-open { font-weight: 700; }
.intent-row__st { color: var(--ink-2); font-family: var(--font-emoji); }

/* ─── Feuilles ─────────────────────────────────────────────────────────── */

.sheet-backdrop { position: fixed; inset: 0; z-index: 20; display: flex; align-items: flex-end; justify-content: center; background: var(--backdrop); animation: fade .2s var(--ease); }
.sheet {
  width: 100%; max-width: 640px; height: var(--vvh, 100dvh);
  display: flex; flex-direction: column; background: var(--paper);
  animation: sheet-in .28s var(--ease); outline: none;
}
@media (min-width: 700px) {
  .sheet-backdrop { align-items: center; }
  .sheet { height: auto; max-height: min(88vh, 900px); border-radius: 22px; box-shadow: var(--shadow); overflow: hidden; }
}
@keyframes sheet-in { from { transform: translateY(28px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.sheet__head { flex: none; display: flex; align-items: center; gap: 4px; min-height: 56px; padding: env(safe-area-inset-top) 8px 0; border-bottom: 1px solid var(--rule); }
.sheet__title { flex: 1; min-width: 0; margin: 0; font-size: 17px; font-weight: 700; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sheet__action { min-width: 44px; display: flex; justify-content: flex-end; }
.sheet__body { flex: 1; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; padding: 14px 16px 28px; }
.sheet__foot { flex: none; padding: 10px 16px calc(10px + env(safe-area-inset-bottom)); border-top: 1px solid var(--rule); background: var(--paper); }
@media (min-width: 700px) { .sheet__head { padding-top: 0; } .sheet__foot { padding-bottom: 12px; } }
.lede { margin: 4px 0 12px; font-size: 16px; line-height: 1.5; }

/* ─── Boutons, champs ──────────────────────────────────────────────────── */

.btn {
  min-height: 44px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 0 16px;
  border: 1px solid var(--rule); border-radius: 13px; background: var(--paper); color: var(--ink);
  font-size: 16px; font-weight: 600; text-decoration: none; transition: transform .12s var(--ease), background .15s;
}
.btn:active { transform: scale(.98); }
.btn--primary { border-color: transparent; background: var(--primary-bg); color: var(--primary-fg); }
.btn--quiet { border-color: transparent; background: none; color: var(--ink-2); }
.btn--danger { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 32%, var(--rule)); }
.btn--block { width: 100%; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0; }
.btn-row > .btn { flex: 1 1 auto; }
.btn-col { display: grid; gap: 8px; margin: 10px 0; }
.btn-icon { width: 44px; height: 44px; flex: none; display: grid; place-items: center; border: 0; border-radius: 13px; background: none; color: var(--ink); }
.btn-icon:active { background: var(--paper-2); }
.btn-icon--small { width: 36px; height: 36px; }
.btn-icon--framed { border: 1px solid var(--rule); width: 48px; height: 48px; }
.footer-actions { display: flex; align-items: center; gap: 8px; }
.icon { display: block; flex: none; }

.field { margin: 16px 0; }
.field__label { display: block; margin: 0 0 7px; font-size: 13px; font-weight: 700; letter-spacing: .03em; color: var(--ink-2); }
.field__label small { font-weight: 400; letter-spacing: 0; margin-left: 4px; }
.field__hint { margin: 7px 0; font-size: 13.5px; line-height: 1.45; color: var(--ink-2); }
.input {
  width: 100%; min-height: 48px; padding: 0 14px; border: 1px solid var(--rule); border-radius: 13px;
  background: var(--paper); color: var(--ink); font-size: 17px; outline: none; -webkit-appearance: none; appearance: none;
}
.input:focus { border-color: var(--ink); box-shadow: 0 0 0 1px var(--ink); }
.input--area { padding: 12px 14px; line-height: 1.45; resize: vertical; }
.input--paste { font-family: var(--font-mono); font-size: 15px; }
.input--sign { min-height: 58px; text-align: center; font-family: var(--font-emoji); font-size: 30px; letter-spacing: 4px; }
.input--bare { border: 0; min-height: 40px; padding: 0; background: none; box-shadow: none !important; }
.inline { display: flex; gap: 8px; align-items: stretch; margin: 6px 0; }
.inline > .input { flex: 1; min-width: 0; }
.check { display: flex; align-items: center; gap: 10px; padding: 8px 0; font-size: 15.5px; }
.check input { width: 20px; height: 20px; accent-color: var(--primary-bg); }
.check small { margin-left: auto; color: var(--ink-2); font-size: 12.5px; text-align: right; }

.chip {
  flex: none; display: inline-flex; align-items: center; gap: 7px; min-height: 36px; padding: 0 14px;
  border: 1px solid var(--rule); border-radius: 18px; background: none; color: var(--ink); font-size: 15px; white-space: nowrap;
}
.chip small { color: var(--ink-2); font-size: 12.5px; }
.chip[data-ink]::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--c); }
.chip.is-on { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.chip.is-on small { color: color-mix(in srgb, var(--paper) 75%, transparent); }
.chip.is-on[data-ink]::before { box-shadow: 0 0 0 1.5px var(--paper); }
.chips--wrap { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.chips--select .chip { color: var(--ink-3); border-style: dashed; }
.chips--select .chip.is-on { background: var(--paper-2); color: var(--ink); border: 1px solid var(--ink); }
.chips--select .chip.is-on::after { content: "✓"; font-size: 13px; margin-left: -2px; }
.chips--scroll { display: flex; gap: 6px; margin: 8px -16px; padding: 0 16px 2px; overflow-x: auto; scrollbar-width: none; }

.segmented { display: flex; gap: 3px; margin: 12px 0; padding: 3px; border-radius: 13px; background: var(--paper-2); }
.segmented > button { flex: 1; min-height: 38px; padding: 0 8px; border: 0; border-radius: 10px; background: none; color: var(--ink-2); font-size: 15px; font-weight: 600; }
.segmented > button.is-on { background: var(--seg-on); color: var(--ink); box-shadow: 0 1px 2px rgba(0, 0, 0, .12); }

.switch { position: relative; display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 10px 0; }
.switch__text { display: flex; flex-direction: column; font-size: 16px; }
.switch__text small { color: var(--ink-2); font-size: 13px; }
.switch input { position: absolute; right: 0; width: 52px; height: 32px; margin: 0; opacity: 0; cursor: pointer; }
.switch__track { position: relative; flex: none; width: 52px; height: 32px; border-radius: 16px; background: var(--paper-3); transition: background .2s var(--ease); pointer-events: none; }
.switch__track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 26px; height: 26px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .25); transition: transform .22s var(--ease); }
.switch input:checked + .switch__track { background: var(--primary-bg); }
.switch input:checked + .switch__track::after { transform: translateX(20px); }
.switch input:focus-visible + .switch__track { outline: 2px solid var(--ink); outline-offset: 2px; }

.notice { margin: 12px 0; padding: 12px 14px; border-radius: 14px; background: var(--paper-2); font-size: 15px; line-height: 1.45; text-align: left; }
.notice--warn { background: var(--warn-bg); }
.notice__actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.notice__actions .btn { min-height: 40px; font-size: 15px; }

/* ─── Formulaire d'entrée ──────────────────────────────────────────────── */

.entry-form__sign { display: flex; flex-direction: column; align-items: center; gap: 2px; margin: 2px 0 6px; }
.sign-pick { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 4px 12px; border: 0; border-radius: 20px; background: none; color: var(--ink-2); font-size: 13.5px; }
.sign-pick:disabled { opacity: 1; }
.small-caps { margin: 2px 0; font-size: 12px; font-weight: 650; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-2); }
.entry-form__actions { display: grid; gap: 6px; margin: 18px 0 0; }
.new-chapter { display: grid; gap: 6px; margin: 8px 0 0; padding: 12px; border-radius: 14px; background: var(--paper-2); }
.define__hint { margin: 0 0 6px; padding: 8px 12px; border-radius: 12px; background: var(--paper-2); color: var(--ink-2); font-size: 14px; text-align: center; }
.define__progress { margin: 12px 0 0; text-align: center; color: var(--ink-3); font-size: 12.5px; font-variant-numeric: tabular-nums; }
.done-state { display: grid; gap: 12px; justify-items: center; padding: 40px 8px; text-align: center; }
.done-state__title { margin: 0; font-size: 24px; font-weight: 780; letter-spacing: -.01em; }

/* ─── Fiche ────────────────────────────────────────────────────────────── */

.fiche { text-align: center; }
.fiche__seal { display: flex; justify-content: center; margin: 10px 0 12px; }
.seal-btn { padding: 0; border: 0; border-radius: 50%; background: none; }
.seal-btn:active { transform: scale(.97); }
.fiche__name { margin: 6px 0 4px; font-size: 28px; line-height: 34px; font-weight: 780; letter-spacing: -.015em; overflow-wrap: anywhere; }
.fiche__says { margin: 2px 0; color: var(--ink-2); font-style: italic; font-size: 14px; }
.fiche__note { max-width: 34em; margin: 10px auto 0; color: var(--ink-2); font-size: 15px; line-height: 1.5; }
.fiche__source { display: inline-flex; align-items: center; gap: 6px; margin: 10px 0 0; color: var(--ink-3); font: 12px var(--font-mono); overflow-wrap: anywhere; }
.fiche__actions { display: grid; gap: 8px; margin: 20px 0 0; text-align: left; }
.fiche__actions .btn-row { margin: 0; }
.ledger { margin: 24px 0 0; text-align: left; }
.ledger ol { margin: 0; padding: 0; list-style: none; }
.ledger li { padding: 8px 0; border-bottom: 1px solid var(--rule); font-size: 15px; }
.ledger__date { display: inline-block; min-width: 64px; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.ledger__signs { font-family: var(--font-emoji); }
.ledger__why { color: var(--ink-2); font-style: italic; }
.etym { margin: 28px 0 0; color: var(--ink-3); font-size: 12px; letter-spacing: .02em; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.mue { text-align: center; }
.mue__line { display: flex; align-items: center; justify-content: center; gap: 16px; margin: 16px 0 8px; }
.mue__arrow { font-size: 26px; color: var(--ink-2); }
.mue__name { margin: 0 0 8px; font-size: 20px; font-weight: 700; }
.mue .field { text-align: left; }

/* ─── Relire ───────────────────────────────────────────────────────────── */

.relire { text-align: center; }
.relire__name { margin: 4px 0 12px; font-size: 32px; line-height: 1.1; font-weight: 800; letter-spacing: -.02em; overflow-wrap: anywhere; }
.relire__seal { display: flex; justify-content: center; margin: 6px 0 12px; }
.relire__q { margin: 14px 0 12px; font-size: 18px; font-weight: 650; }
.relire__choices { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.relire__choices .cand { height: 70px; }
.relire__ok { margin: 16px 0; font-size: 22px; font-weight: 780; color: var(--c); }

/* ─── Partager, importer, réglages ─────────────────────────────────────── */

.preview { margin: 12px 0 4px; padding: 12px 14px; max-height: 42vh; overflow: auto; border-radius: 13px; background: var(--paper-2); white-space: pre-wrap; overflow-wrap: anywhere; font: 13px/1.55 var(--font-mono); }
.count { margin: 4px 0 0; text-align: right; color: var(--ink-2); font-size: 12.5px; font-variant-numeric: tabular-nums; }
.menu { margin: 18px 0 0; padding: 0; list-style: none; }
.menu__item { width: 100%; display: flex; align-items: center; gap: 14px; padding: 12px 2px; border: 0; border-bottom: 1px solid var(--rule); background: none; text-align: left; font-size: 16px; }
.menu__item span { display: flex; flex-direction: column; }
.menu__item small { color: var(--ink-2); font-size: 13px; }
.steps { margin: 8px 0 14px; padding-left: 22px; line-height: 1.55; }
.shortcuts { margin: 10px 0 0; padding: 0; list-style: none; }
.shortcuts li { display: grid; grid-template-columns: 1fr auto; gap: 1px 12px; padding: 8px 0; border-bottom: 1px solid var(--rule); }
.shortcuts__g { grid-row: span 2; align-self: center; font: 24px/1 var(--font-emoji); }
.shortcuts small { color: var(--ink-2); font-size: 12.5px; }
.import-chapters, .import-items { margin: 0; padding: 0; list-style: none; }
.import-chapters li { border-bottom: 1px solid var(--rule); }
.import-items li { display: grid; gap: 4px; padding: 10px 0; border-bottom: 1px solid var(--rule); }
.import-items__signs { color: var(--ink-2); font-size: 14px; font-family: var(--font-emoji); }
.import-items .segmented { margin: 4px 0 0; }
.lines { margin: 14px 0 0; color: var(--ink-2); font-size: 13.5px; }
.lines ul { padding-left: 18px; }
.lines code { font-size: 12px; }
.settings-block { margin: 6px 0 26px; }
.settings-block p { line-height: 1.5; }
.settings-block--danger { padding-top: 14px; border-top: 1px solid var(--rule); }
.inks { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin: 8px 0; }
.ink { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 10px 4px; border: 1px solid var(--rule); border-radius: 14px; background: none; }
.ink span { display: block; width: 28px; height: 28px; border-radius: 50%; background: var(--c); box-shadow: inset 0 0 0 3px var(--paper), 0 0 0 1.5px var(--c); }
.ink small { font-size: 12.5px; }
.ink.is-on { border-color: var(--ink); box-shadow: 0 0 0 1px var(--ink); }

/* ─── Toasts ───────────────────────────────────────────────────────────── */

.toasts { position: fixed; left: 0; right: 0; bottom: calc(18px + env(safe-area-inset-bottom)); z-index: 50; display: flex; justify-content: center; padding: 0 12px; pointer-events: none; }
.toast {
  pointer-events: auto; display: flex; align-items: center; gap: 14px; max-width: min(94vw, 540px);
  padding: 12px 14px 12px 16px; border-radius: 15px; background: var(--ink); color: var(--paper);
  box-shadow: 0 12px 32px rgba(0, 0, 0, .22); font-size: 15px; animation: toast-in .26s var(--ease);
}
.toast--warn { background: var(--warn); color: #fff; }
.toast__text { overflow-wrap: anywhere; }
.toast__action { flex: none; padding: 6px 2px; border: 0; background: none; color: inherit; font-weight: 750; text-decoration: underline; text-underline-offset: 3px; }
@keyframes toast-in { from { transform: translateY(14px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ─── Premier lancement ────────────────────────────────────────────────── */

.firstrun { position: fixed; inset: 0; z-index: 30; overflow-y: auto; background: var(--paper); padding: calc(env(safe-area-inset-top) + 44px) 24px calc(env(safe-area-inset-bottom) + 24px); animation: fade .3s var(--ease); }
.firstrun__inner { max-width: 460px; margin: 0 auto; }
.firstrun__word { margin: 0; color: var(--ink-2); font-size: 16px; }
.firstrun__word i { margin-left: 4px; }
.firstrun__head { font: 800 48px/1 "Codex Archivo", var(--font-ui); letter-spacing: -.035em; color: var(--ink); }
.firstrun__def { margin: 10px 0 20px; font-size: 23px; line-height: 1.3; font-weight: 650; letter-spacing: -.01em; }
.firstrun__senses { margin: 0 0 28px; padding: 0; list-style: none; }
.firstrun__senses li { padding: 8px 0; border-top: 1px solid var(--rule); line-height: 1.45; }
.firstrun__ex { display: block; margin-top: 2px; color: var(--ink-2); font-size: 15px; }
.firstrun__label { display: block; margin: 0 0 10px; color: var(--ink-2); font-size: 15px; line-height: 1.5; }
.firstrun__seals { display: flex; flex-wrap: wrap; gap: 8px; min-height: 52px; margin: 14px 0; }
.firstrun__links { display: flex; justify-content: center; align-items: center; flex-wrap: wrap; gap: 2px; margin: 16px 0 0; color: var(--ink-3); }

/* ─── Erreur ───────────────────────────────────────────────────────────── */

.crash { padding: 24px; text-align: center; }
.crash--full { min-height: 100vh; display: flex; flex-direction: column; justify-content: center; max-width: 420px; margin: 0 auto; }
.crash__title { margin: 0 0 8px; font-size: 26px; font-weight: 800; }
.crash__actions { display: grid; gap: 8px; margin: 18px auto 0; width: 100%; max-width: 320px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .12s !important; animation-delay: 0s !important; transition-duration: .12s !important; }
  .seal.is-stamp, .codex.is-stamping .cell .seal, .cand.is-picked { animation-name: fade !important; }
}
