/* ===== Histoire de famille : styles ===== */
:root {
  --bg: #f6f1e9;
  --paper: #fffdf9;
  --ink: #2a2520;
  --muted: #6e655b;
  --line: #e3d9ca;
  --line-strong: #cdbfa9;
  --accent: #7a3e1d;
  --accent-ink: #fff;
  --accent-soft: #f3e4d6;
  --link: #1d5c86;
  --danger: #b03a2e;
  --ok: #2e7d4f;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(60, 40, 20, .06), 0 4px 14px rgba(60, 40, 20, .06);
  --serif: Georgia, 'Iowan Old Style', 'Palatino Linotype', 'Times New Roman', serif;
  --sans: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --top: 60px;
  --side: 270px;
  color-scheme: light;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 17px/1.6 var(--sans); }
a { color: var(--link); text-underline-offset: 2px; }
a:hover { color: var(--accent); }
h1, h2, h3 { font-family: var(--serif); line-height: 1.25; font-weight: 600; overflow-wrap: anywhere; }
h1 { font-size: 2rem; margin: .2em 0 .4em; }
h2 { font-size: 1.4rem; margin: 1.2em 0 .5em; }
h3 { font-size: 1.12rem; margin: 1em 0 .4em; }
hr { border: 0; border-top: 2px dashed var(--line-strong); margin: 1.5em 0; }
img { max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid #e2a54a; outline-offset: 2px; }
.skip { position: absolute; left: -999px; top: 0; background: #000; color: #fff; padding: 8px 12px; z-index: 1000; }
.skip:focus { left: 8px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.muted { color: var(--muted); }
.small, small { font-size: .85rem; }
.hint { color: var(--muted); font-size: .88rem; margin: .3em 0; }
.loading { padding: 40px; text-align: center; color: var(--muted); }
.row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.grow { flex: 1; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; }

/* ----- Boutons et champs ----- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 16px; border-radius: 10px; border: 1px solid var(--line-strong); background: var(--paper);
  color: var(--ink); text-decoration: none; cursor: pointer; font-weight: 500; line-height: 1.2; min-height: 42px;
}
.btn:hover { background: #fbf4ea; color: var(--ink); border-color: var(--accent); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.primary:hover { background: #64310f; color: #fff; }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.ghost { background: transparent; }
.btn.ghost.danger { color: var(--danger); background: transparent; border-color: #e7c2bd; }
.btn.ghost.danger:hover { background: #fbeceb; }
.btn.small { padding: 6px 12px; min-height: 36px; font-size: .92rem; }
.btn.big { padding: 13px 22px; font-size: 1.08rem; min-height: 50px; }
.btn:disabled { opacity: .5; cursor: wait; }
.icon-btn { background: none; border: 0; font-size: 1.3rem; cursor: pointer; padding: 6px 10px; border-radius: 8px; }
.icon-btn:hover { background: rgba(0, 0, 0, .06); }
input[type=text], input[type=search], input[type=email], input[type=password], input:not([type]), select, textarea {
  border: 1px solid var(--line-strong); border-radius: 10px; padding: 9px 12px; background: #fff; min-height: 44px; width: 100%;
}
select { width: auto; cursor: pointer; }
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); outline: 3px solid rgba(226, 165, 74, .35); outline-offset: 0; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field > span, .field .lbl { font-weight: 600; font-size: .95rem; }
.field.inline { flex-direction: row; align-items: center; gap: 8px; }
.check { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
.check input { width: 20px; height: 20px; accent-color: var(--accent); }
.check.big { font-weight: 600; }
.card { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow); }
.notice { background: #fff6dd; border: 1px solid #ecd697; border-radius: 10px; padding: 12px 16px; display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between; }
.badge { display: inline-block; background: var(--accent-soft); color: var(--accent); border-radius: 999px; padding: 1px 10px; font-size: .78rem; font-weight: 600; margin-left: 8px; }
.badge-vivant { background: #e3f3e8; color: var(--ok); }
.badge-count { background: var(--danger); color: #fff; border-radius: 999px; padding: 0 8px; font-size: .78rem; margin-left: 8px; }
.form-error { background: #fbeceb; color: var(--danger); border: 1px solid #efc9c4; padding: 10px 14px; border-radius: 10px; margin: 0; }
.success { background: #e7f5ec; border: 1px solid #b9dfc6; padding: 12px 16px; border-radius: 10px; }

/* ----- Messages et fenêtres ----- */
#toasts { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 2000; display: flex; flex-direction: column; gap: 8px; width: min(92vw, 520px); }
.toast { background: #2a2520; color: #fff; padding: 12px 18px; border-radius: 12px; box-shadow: 0 6px 24px rgba(0, 0, 0, .25); transition: opacity .5s, transform .5s; font-weight: 500; }
.toast-error { background: var(--danger); }
.toast-info { background: #1d5c86; }
.toast.out { opacity: 0; transform: translateY(10px); }
.modal-overlay { position: fixed; inset: 0; background: rgba(30, 20, 10, .45); display: flex; align-items: flex-start; justify-content: center; padding: 6vh 12px; z-index: 1500; overflow-y: auto; }
.modal { background: var(--paper); border-radius: 16px; width: min(560px, 100%); box-shadow: 0 20px 60px rgba(0, 0, 0, .3); }
.modal-wide { width: min(900px, 100%); }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px 0; }
.modal-head h2 { margin: 0; font-size: 1.3rem; }
.modal-body { padding: 14px 20px; }
.modal-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 10px; padding: 0 20px 18px; }
.lightbox { text-align: center; }
.lightbox img { max-height: 75vh; border-radius: 8px; }
.temp-pw { font: 600 1.6rem/1.3 ui-monospace, Menlo, Consolas, monospace; background: var(--accent-soft); padding: 12px; border-radius: 10px; text-align: center; letter-spacing: .03em; user-select: all; }

/* ----- Cadre ----- */
.topbar {
  position: sticky; top: 0; z-index: 900; height: var(--top); display: flex; align-items: center; gap: 14px; padding: 0 16px;
  background: #3b2416; color: #fdf6ea; box-shadow: 0 2px 8px rgba(0, 0, 0, .15);
}
.topbar .icon-btn { color: #fdf6ea; }
.burger { display: none; }
.brand { display: flex; align-items: center; gap: 10px; color: #fdf6ea; text-decoration: none; font: 600 1.15rem var(--serif); white-space: nowrap; }
.brand:hover { color: #fff; }
.brand-ico { font-size: 1.4rem; }
.search { position: relative; flex: 1; max-width: 520px; margin-left: auto; }
.search input { background: rgba(255, 255, 255, .95); border: 0; min-height: 40px; }
.suggest { position: absolute; top: 46px; left: 0; right: 0; background: #fff; color: var(--ink); list-style: none; margin: 0; padding: 6px; border-radius: 12px; box-shadow: 0 10px 30px rgba(0, 0, 0, .2); z-index: 950; }
.suggest a { display: block; padding: 8px 12px; border-radius: 8px; color: var(--ink); text-decoration: none; }
.suggest li.sel a, .suggest a:hover { background: var(--accent-soft); }
.suggest .all a { color: var(--link); border-top: 1px solid var(--line); margin-top: 4px; }
.new-btn { white-space: nowrap; background: #e2a54a; border-color: #e2a54a; color: #2a1608; }
.new-btn:hover { background: #f0b65e; color: #2a1608; }
.user-menu { position: relative; }
.user-menu summary { list-style: none; display: flex; align-items: center; gap: 8px; cursor: pointer; padding: 4px 8px; border-radius: 10px; }
.user-menu summary::-webkit-details-marker { display: none; }
.user-menu summary:hover { background: rgba(255, 255, 255, .1); }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: #e2a54a; color: #2a1608; display: grid; place-items: center; font-weight: 700; }
.um-pop { position: absolute; right: 0; top: 48px; background: #fff; color: var(--ink); border-radius: 12px; box-shadow: 0 10px 30px rgba(0, 0, 0, .2); min-width: 230px; padding: 8px; display: flex; flex-direction: column; }
.um-pop a, .um-pop button { padding: 10px 12px; border-radius: 8px; text-decoration: none; color: var(--ink); background: none; border: 0; text-align: left; cursor: pointer; }
.um-pop a:hover, .um-pop button:hover { background: var(--accent-soft); }
.um-role { padding: 6px 12px 10px; font-size: .85rem; color: var(--muted); border-bottom: 1px solid var(--line); margin-bottom: 4px; }

.layout { display: flex; min-height: calc(100vh - var(--top)); }
.sidebar { width: var(--side); flex-shrink: 0; background: #efe6d8; border-right: 1px solid var(--line); padding: 14px 10px 40px; position: sticky; top: var(--top); height: calc(100vh - var(--top)); overflow-y: auto; }
.nav-main { display: flex; flex-direction: column; gap: 2px; margin-bottom: 14px; }
.nav-link { display: flex; align-items: center; padding: 9px 12px; border-radius: 10px; color: var(--ink); text-decoration: none; font-weight: 500; }
.nav-link:hover, .nav-note:hover { background: rgba(122, 62, 29, .08); color: var(--ink); }
.nav-link.active, .nav-note.active { background: var(--accent); color: #fff; }
.nav-title { text-transform: uppercase; font-size: .75rem; letter-spacing: .08em; color: var(--muted); padding: 8px 12px 4px; font-weight: 700; }
.nav-group summary { display: flex; justify-content: space-between; padding: 8px 12px; border-radius: 10px; cursor: pointer; font-weight: 600; list-style: none; }
.nav-group summary::before { content: '▸'; margin-right: 6px; transition: transform .15s; display: inline-block; }
.nav-group[open] summary::before { transform: rotate(90deg); }
.nav-group summary::-webkit-details-marker { display: none; }
.nav-group summary > span:first-child { flex: 1; }
.nav-group summary:hover { background: rgba(122, 62, 29, .08); }
.count { background: rgba(0, 0, 0, .07); border-radius: 999px; padding: 0 9px; font-size: .8rem; font-weight: 600; }
.nav-group ul { list-style: none; margin: 0 0 6px; padding: 0 0 0 16px; }
.nav-note { display: block; padding: 5px 10px; border-radius: 8px; color: var(--ink); text-decoration: none; font-size: .93rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav-more { display: block; padding: 4px 10px; font-size: .85rem; color: var(--muted); }
.nav-backdrop { display: none; }
.main { flex: 1; min-width: 0; padding: 26px clamp(14px, 3vw, 40px) 80px; }
.main-full { padding: 0; }
.main-auth { min-height: 100vh; }
.page { max-width: 1250px; margin: 0 auto; }
.page.narrow { max-width: 760px; }

/* ----- Connexion ----- */
.auth-page { min-height: 100vh; display: grid; place-items: center; padding: 30px 14px; background: radial-gradient(circle at 20% 10%, #fff8ec, #ead9c0); }
.auth-card { background: var(--paper); width: min(460px, 100%); padding: 32px 30px; border-radius: 18px; box-shadow: 0 10px 40px rgba(60, 40, 20, .15); }
.auth-card h1 { text-align: center; font-size: 1.6rem; margin: 6px 0 2px; }
.auth-card h2 { text-align: center; font-size: 1.1rem; color: var(--muted); font-family: var(--sans); font-weight: 500; margin: 0 0 20px; }
.auth-logo { font-size: 3rem; text-align: center; }
.auth-switch { text-align: center; margin-top: 20px; }
.forgot { margin-top: 14px; color: var(--muted); }
.forgot summary { cursor: pointer; }

/* ----- Fiche ----- */
.note-grid, .home-grid { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 28px; align-items: start; }
.note-side { display: flex; flex-direction: column; gap: 16px; position: sticky; top: calc(var(--top) + 16px); }
.side-card { padding: 14px 16px; }
.side-card h3 { margin: 0 0 10px; font-size: 1.02rem; }
.side-card ul { margin: 0; padding-left: 0; list-style: none; }
.side-card li { padding: 4px 0; }
.note-type { display: flex; align-items: center; gap: 6px; font-weight: 600; color: var(--tc, var(--accent)); text-transform: uppercase; letter-spacing: .05em; font-size: .85rem; }
.note-type a { color: inherit; text-decoration: none; }
.note-title { font-size: clamp(1.7rem, 3vw, 2.4rem); margin: .1em 0 .2em; }
.aliases { margin: 0 0 8px; color: var(--muted); font-style: italic; }
.note-actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0 18px; }
.home-actions { justify-content: flex-end; margin: 0; }
.props-card { margin-bottom: 16px; padding: 14px 20px; border-left: 5px solid var(--tc, var(--accent)); }
.props { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(230px, 100%), 1fr)); gap: 10px 24px; margin: 0; }
.prop dt { font-size: .82rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
.prop dd { margin: 2px 0 0; }
.chips { display: inline-flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-block; padding: 3px 11px; border-radius: 999px; background: #eef3f7; color: var(--link); text-decoration: none; font-size: .93rem; border: 1px solid #d5e2ec; }
.chip:hover { background: #dbe9f3; color: var(--link); }
.chip-sm { font-size: .85rem; padding: 2px 9px; }
.chip-personne { background: #eaf2fa; } .chip-lieu { background: #fdf0e6; border-color: #f2d6c0; color: #a1460a; }
.chip-bien { background: #f7f0e6; border-color: #e7d6bd; color: #7a5124; } .chip-anecdote { background: #f4ecf8; border-color: #e1d0ea; color: #6e2e8a; }
.chip-source { background: #f1f2f2; border-color: #dcdfe0; color: #4d5657; } .chip-missing { background: #f6e5e3; color: var(--danger); border-color: #edc8c3; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tag { font-size: .85rem; background: var(--accent-soft); color: var(--accent); padding: 2px 10px; border-radius: 999px; text-decoration: none; }
.note-body { margin-top: 8px; }
.empty-note { color: var(--muted); font-style: italic; padding: 30px; text-align: center; border: 2px dashed var(--line-strong); border-radius: var(--radius); }
.meta p { margin: 0 0 8px; font-size: .88rem; color: var(--muted); }
.meta strong { color: var(--ink); }
.fam-row { display: flex; flex-direction: column; gap: 4px; margin-bottom: 10px; }
.fam-lbl { font-size: .8rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
.mini-map { height: 200px; border-radius: 10px; overflow: hidden; }
.backlinks a { text-decoration: none; }

/* Contenu */
.rt { margin: .6em 0; }
.rt p { margin: 0 0 .6em; }
.bh { border-bottom: 2px solid var(--line); padding-bottom: 4px; }
a.notelink { text-decoration: none; border-bottom: 1px solid currentColor; font-weight: 500; }
a.nl-personne { color: #1d5c86; } a.nl-lieu { color: #a1460a; } a.nl-bien { color: #7a5124; } a.nl-anecdote { color: #6e2e8a; } a.nl-source { color: #4d5657; } a.nl-page { color: #0f6e5f; }
.notelink-missing { color: var(--danger); text-decoration: line-through dotted; }
mark { background: #ffe79a; padding: 0 2px; border-radius: 3px; }
.callout { --c: 41, 128, 185; background: rgba(var(--c), .07); border-left: 5px solid rgb(var(--c)); border-radius: 10px; padding: 12px 16px; margin: 16px 0; }
.callout .co-head { display: flex; align-items: center; gap: 8px; font-weight: 700; color: rgb(var(--c)); font-family: var(--serif); font-size: 1.08rem; }
details.callout > summary { cursor: pointer; list-style: none; }
details.callout > summary::-webkit-details-marker { display: none; }
details.callout > summary::after { content: '▾'; margin-left: auto; transition: transform .2s; }
details.callout:not([open]) > summary::after { transform: rotate(-90deg); }
.co-more { font: 400 .8rem var(--sans); color: var(--muted); margin-left: 6px; }
details.callout[open] .co-more { display: none; }
.co-body > :first-child { margin-top: 8px; }
.co-body > :last-child { margin-bottom: 0; }
.co-body .table-wrap { margin: 8px 0; }
.table-wrap { overflow-x: auto; margin: 12px 0; }
table { border-collapse: collapse; width: 100%; background: var(--paper); border-radius: 8px; overflow: hidden; }
th, td { padding: 8px 12px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--line); }
th { background: #f2ebe0; font-size: .88rem; text-transform: uppercase; letter-spacing: .03em; color: #5a4f45; }
table.kv td:first-child { font-weight: 600; white-space: nowrap; width: 1%; }
.callout table { background: rgba(255, 255, 255, .7); }
.timeline .tl-date { white-space: nowrap; font-weight: 700; color: var(--accent); }
.fiab { white-space: nowrap; font-size: .9rem; }
.fiab-confirme .fiab-txt { color: var(--ok); } .fiab-temoignage .fiab-txt { color: #8a6d1f; } .fiab-verifier .fiab-txt { color: var(--danger); }
figure { margin: 16px 0; }
figure.img-s { max-width: 280px; } figure.img-m { max-width: 520px; } figure.img-l { max-width: 100%; }
figure img { display: block; border-radius: 8px; box-shadow: var(--shadow); }
.img-btn { padding: 0; border: 0; background: none; cursor: zoom-in; display: block; }
figcaption { font-size: .9rem; color: var(--muted); margin-top: 6px; font-style: italic; }
.co-body figure { display: inline-block; margin: 6px 8px 6px 0; vertical-align: top; }
.pdf-card { display: inline-flex; align-items: center; gap: 12px; padding: 12px 16px; border: 1px solid var(--line-strong); border-radius: 10px; background: #fff; text-decoration: none; color: var(--ink); }
.pdf-card small { display: block; color: var(--link); }
.pdf-ico { font-size: 2rem; }
.questions ul { list-style: none; padding: 0; margin: 6px 0; }
.questions li { padding: 4px 0; }
.questions label { display: flex; gap: 10px; align-items: flex-start; cursor: pointer; }
.questions input { width: 20px; height: 20px; margin-top: 3px; accent-color: var(--ok); flex-shrink: 0; }
.questions li.done span { text-decoration: line-through; color: var(--muted); }
.q-title { font-weight: 700; font-family: var(--serif); }
.blist { padding-left: 24px; }
blockquote.temoin { margin: 16px 0; padding: 14px 20px; background: #fbf7ef; border-left: 5px solid #b38b59; border-radius: 10px; font-family: var(--serif); font-size: 1.05rem; }
blockquote.temoin footer { font-family: var(--sans); font-size: .9rem; color: var(--muted); margin-top: 6px; }

/* ----- Accueil ----- */
.quick-add { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.qa { display: block; padding: 10px; border-radius: 10px; border: 1px solid var(--line); text-decoration: none; color: var(--ink); background: #fff; border-left: 4px solid var(--tc); font-weight: 500; }
.qa:hover { background: #fbf4ea; color: var(--ink); }
.stats a { text-decoration: none; color: var(--ink); }
.recent li { display: flex; flex-direction: column; padding: 6px 0; border-bottom: 1px solid var(--line); }
.recent li:last-child { border: 0; }
.recent small { color: var(--muted); }

/* ----- Listes ----- */
.list-head { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 10px; }
.list-filter { max-width: 420px; margin-bottom: 8px; }
.list-table a { text-decoration: none; font-weight: 500; }
.list-table tr:hover td { background: #fbf6ee; }
.list-table td.actions { white-space: nowrap; display: flex; gap: 6px; flex-wrap: wrap; }
.search-results { display: flex; flex-direction: column; gap: 10px; margin-top: 14px; }
.result { display: flex; flex-direction: column; gap: 4px; text-decoration: none; color: var(--ink); }
.result:hover { border-color: var(--accent); color: var(--ink); }
.result small { color: var(--muted); }
.q-group { margin-bottom: 14px; }
.q-group h2 { margin-top: 0; font-size: 1.15rem; }
.q-group h2 a { text-decoration: none; }
.history { padding-left: 22px; }
.history li { padding: 6px 0; }

/* ----- Édition ----- */
.edit-page { max-width: 1050px; }
.edit-bar { position: sticky; top: var(--top); z-index: 800; display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; background: var(--bg); padding: 10px 0; border-bottom: 1px solid var(--line); }
.edit-bar-left { display: flex; flex-direction: column; }
.edit-bar-right { display: flex; gap: 8px; }
.save-status { font-size: .88rem; color: var(--muted); }
.save-status.dirty { color: #b5651d; font-weight: 600; }
.toolbar { position: sticky; top: calc(var(--top) + 64px); z-index: 790; display: flex; flex-wrap: wrap; gap: 4px; align-items: center; background: var(--paper); border: 1px solid var(--line); border-radius: 12px; padding: 6px; margin: 10px 0 16px; box-shadow: var(--shadow); transition: opacity .2s; }
.toolbar.inactive { opacity: .55; }
.tb-btn { min-width: 40px; height: 38px; border: 1px solid transparent; background: none; border-radius: 8px; cursor: pointer; padding: 0 10px; font-size: .95rem; }
.tb-btn:hover { background: var(--accent-soft); border-color: var(--line-strong); }
.tb-sep { width: 1px; height: 26px; background: var(--line); margin: 0 4px; }
.edit-section { margin-bottom: 18px; }
.edit-section h2 { margin: 0 0 12px; font-size: 1.2rem; }
details.edit-section > summary { display: flex; align-items: baseline; gap: 10px; cursor: pointer; list-style: none; }
details.edit-section > summary h2 { margin: 0; }
details.edit-section > summary::-webkit-details-marker { display: none; }
details.edit-section[open] > summary { margin-bottom: 12px; }
.title-input { font: 600 1.5rem var(--serif); }
.props-form { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(260px, 100%), 1fr)); gap: 14px 20px; margin-bottom: 16px; }
.link-field { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; min-height: 44px; padding: 5px; border: 1px dashed var(--line-strong); border-radius: 10px; background: #fff; }
.chip-edit { display: inline-flex; align-items: center; gap: 4px; background: #eef3f7; border: 1px solid #d5e2ec; border-radius: 999px; padding: 3px 4px 3px 11px; font-size: .92rem; }
.chip-edit.tag { background: var(--accent-soft); border-color: #e7cdb6; }
.chip-edit button { border: 0; background: rgba(0, 0, 0, .07); border-radius: 50%; width: 24px; height: 24px; cursor: pointer; line-height: 1; }
.chip-edit button:hover { background: var(--danger); color: #fff; }
.tag-in { flex: 1; min-width: 160px; border: 0 !important; min-height: 34px !important; }
.content-section > h2 { margin-bottom: 4px; }
.edit-footer { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 10px; margin-top: 24px; padding-top: 16px; border-top: 1px solid var(--line); }

.eblocks { display: flex; flex-direction: column; gap: 12px; }
.eb { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.eb:focus-within { border-color: #e2a54a; box-shadow: 0 0 0 3px rgba(226, 165, 74, .25); }
.eb-bar { display: flex; justify-content: space-between; align-items: center; padding: 4px 6px 4px 12px; border-bottom: 1px solid var(--line); background: #faf5ec; border-radius: var(--radius) var(--radius) 0 0; }
.eb-label { font-size: .8rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.eb-ctls { display: flex; gap: 2px; }
.eb-ctl { min-width: 34px; height: 32px; border: 1px solid transparent; border-radius: 8px; background: none; cursor: pointer; font-size: .95rem; }
.eb-ctl:hover { background: #fff; border-color: var(--line-strong); }
.eb-ctl.danger:hover { background: #fbeceb; border-color: #efc9c4; }
.eb-ctl.off { opacity: .3; pointer-events: none; }
.eb-body { padding: 12px; }
.depth-1 .eb { box-shadow: none; }
.add-block { border: 2px dashed var(--line-strong); background: transparent; border-radius: var(--radius); padding: 14px; cursor: pointer; color: var(--muted); font-weight: 600; font-size: 1rem; }
.add-block:hover { border-color: var(--accent); color: var(--accent); background: #fff8ef; }
.depth-1 .add-block { padding: 8px; font-size: .92rem; }

.rte { min-height: 2.6em; padding: 8px 12px; border: 1px solid var(--line); border-radius: 10px; background: #fff; outline: none; word-wrap: break-word; }
.rte:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(226, 165, 74, .25); }
.rte.empty::before { content: attr(data-placeholder); color: #a89c8e; pointer-events: none; position: absolute; }
.rte-cell { min-height: 2.2em; padding: 5px 8px; font-size: .95rem; }
.rte-line { min-height: 2.2em; padding: 5px 10px; flex: 1; }
.rte-quote { font-family: var(--serif); font-size: 1.05rem; min-height: 5em; background: #fbf7ef; }
.rte-caption { margin-top: 8px; font-style: italic; font-size: .93rem; }
.heading-input { font-family: var(--serif); font-weight: 600; flex: 1; }
.heading-input.lvl-2 { font-size: 1.35rem; } .heading-input.lvl-3 { font-size: 1.1rem; }
.callout-edit { margin: 0; }
.callout-edit .co-title-input { font: 700 1.05rem var(--serif); color: rgb(var(--c)); background: rgba(255, 255, 255, .8); }
.callout-edit .co-head { margin: 8px 0; }
.callout-edit .co-body { margin-top: 10px; }
.variant-details summary { cursor: pointer; font-size: .9rem; color: var(--muted); }
.variant-pick { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.vp { border: 2px solid rgba(var(--c), .35); background: rgba(var(--c), .1); color: rgb(var(--c)); border-radius: 999px; padding: 4px 12px; cursor: pointer; font-size: .88rem; font-weight: 600; }
.vp.on { background: rgb(var(--c)); color: #fff; border-color: rgb(var(--c)); }
table.editing td { padding: 4px; }
table.editing .tl-date-in { min-width: 110px; }
table.editing select { min-height: 38px; font-size: .9rem; padding: 4px 6px; }
table.editing td.row-ctl { width: 1%; white-space: nowrap; }
table.editing tr.th-row .rte { font-weight: 700; background: #f2ebe0; }
.upload-zone { display: flex; align-items: center; justify-content: center; text-align: center; width: 100%; min-height: 140px; border: 2px dashed var(--line-strong); border-radius: 12px; background: #fdfaf4; cursor: pointer; padding: 14px; }
.upload-zone:hover, .upload-zone.over { border-color: var(--accent); background: #fff4e6; }
.upload-zone > span { display: flex; flex-direction: column; gap: 4px; align-items: center; }
.upload-zone img { max-height: 260px; border-radius: 8px; }
.uz-ico { font-size: 2.2rem; }
.img-edit.busy { opacity: .5; pointer-events: none; }
.img-edit .row { margin-top: 8px; }
.q-edit ul, .l-edit ul, .l-edit ol { list-style: none; padding: 0; margin: 8px 0; display: flex; flex-direction: column; gap: 6px; }
.l-edit ol { list-style: decimal; padding-left: 24px; }
.q-edit li, .l-edit li { display: flex; align-items: center; gap: 8px; }
.q-edit li > input { width: 22px; height: 22px; accent-color: var(--ok); }
.q-title-in { font-weight: 700; }
.quote-edit .row { margin-top: 8px; }
.place-edit .row { margin: 6px 0; }
.place-edit input[type=search] { flex: 1; min-width: 220px; }
.place-map { height: 340px; border-radius: 10px; border: 1px solid var(--line); margin: 8px 0; }
.addr-results { list-style: none; padding: 0; margin: 0; }
.addr-results button { width: 100%; text-align: left; border: 0; background: #fff; padding: 8px 12px; border-bottom: 1px solid var(--line); cursor: pointer; }
.addr-results button:hover { background: var(--accent-soft); }
.addr-results .muted { padding: 8px 12px; }

/* Menu d'insertion */
.insert-menu h3 { margin: 6px 0 10px; font-size: 1rem; color: var(--muted); font-family: var(--sans); text-transform: uppercase; letter-spacing: .05em; }
.block-grid, .tpl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px; margin-bottom: 18px; }
.block-card, .tpl-card { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; background: #fff; cursor: pointer; text-align: left; }
.block-card:hover, .tpl-card:hover { border-color: var(--accent); background: #fff8ef; }
.block-card small, .tpl-card small { color: var(--muted); font-size: .82rem; line-height: 1.35; }
.bc-ico { font-size: 1.5rem; height: 32px; }
.type-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.type-card { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 18px 10px; border: 2px solid var(--line); border-radius: 14px; background: #fff; cursor: pointer; font-weight: 600; border-bottom: 5px solid var(--tc); }
.type-card:hover { border-color: var(--tc); background: #fffaf3; }
.tc-ico { font-size: 2rem; }
.picker input[type=search] { margin-bottom: 8px; }
.pick-types { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.pill { border: 1px solid var(--line-strong); background: #fff; border-radius: 999px; padding: 4px 12px; cursor: pointer; font-size: .88rem; }
.pill.on { background: var(--accent); color: #fff; border-color: var(--accent); }
.pick-list { list-style: none; padding: 0; margin: 0; max-height: 50vh; overflow-y: auto; border: 1px solid var(--line); border-radius: 10px; }
.pick-list li { padding: 10px 14px; cursor: pointer; display: flex; gap: 8px; border-bottom: 1px solid var(--line); }
.pick-list li:last-child { border: 0; }
.pick-list li:hover, .pick-list li.sel { background: var(--accent-soft); }
.pick-empty { color: var(--muted); cursor: default !important; }
.pick-create { color: var(--accent); font-weight: 600; }

/* ----- Carte ----- */
.map-page { display: grid; grid-template-columns: 320px 1fr; height: calc(100vh - var(--top)); }
.map-panel { overflow-y: auto; padding: 16px; background: var(--paper); border-right: 1px solid var(--line); }
.map-panel h1 { font-size: 1.4rem; margin-top: 0; }
.map-panel h2 { font-size: 1.05rem; }
.filters { border: 1px solid var(--line); border-radius: 10px; margin: 12px 0; padding: 8px 12px; display: flex; flex-direction: column; gap: 4px; }
.filters legend { font-weight: 700; padding: 0 6px; }
.swatch { width: 12px; height: 12px; border-radius: 50%; display: inline-block; }
.map-list { list-style: none; padding: 0; margin: 0; }
.map-list button { width: 100%; text-align: left; background: none; border: 0; padding: 7px 8px; border-radius: 8px; cursor: pointer; }
.map-list button:hover { background: var(--accent-soft); }
.unplaced { margin-top: 16px; }
.unplaced summary { cursor: pointer; font-weight: 600; }
.big-map { height: 100%; min-height: 400px; }
.map-missing { display: grid; place-items: center; height: 100%; min-height: 200px; padding: 20px; text-align: center; color: var(--muted); background: #efe6d8; border-radius: 10px; }
.fm-marker span { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50% 50% 50% 0; transform: rotate(-45deg); background: var(--mc); border: 3px solid #fff; box-shadow: 0 2px 6px rgba(0, 0, 0, .35); font-size: 16px; }
.fm-marker { background: none; border: 0; }
.fm-marker span > i { transform: rotate(45deg); font-style: normal; line-height: 1; }
.map-popup { display: flex; flex-direction: column; gap: 6px; font: 15px/1.4 var(--sans); }
.mp-type { font-size: .8rem; color: var(--muted); text-transform: uppercase; }
.mp-title { font: 600 1.05rem var(--serif); text-decoration: none; }
.mp-rel ul { margin: 2px 0; padding-left: 18px; }
.map-popup .btn { color: #fff; }

/* ----- Arbre ----- */
.tree-page { display: flex; flex-direction: column; height: calc(100vh - var(--top)); padding: 14px clamp(12px, 2vw, 24px); }
.tree-head { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 10px; }
.tree-head h1 { margin: 0; font-size: 1.5rem; }
.tree-head input { width: 240px; }
.tree-viewport { flex: 1; overflow: auto; background: repeating-linear-gradient(0deg, transparent 0 39px, rgba(0, 0, 0, .025) 39px 40px), repeating-linear-gradient(90deg, transparent 0 39px, rgba(0, 0, 0, .025) 39px 40px), #fbf7f0; border: 1px solid var(--line); border-radius: var(--radius); cursor: grab; position: relative; }
.tree-viewport.dragging { cursor: grabbing; user-select: none; }
.tree-canvas { position: relative; transform-origin: 0 0; margin: 10px; }
.tree-lines { position: absolute; left: 0; top: 0; pointer-events: none; }
.tree-lines path { fill: none; stroke: #9c8b76; stroke-width: 2; }
.tree-lines path.e-spouse { stroke: #c0392b; stroke-width: 3; }
.tree-lines path.e-ghost { stroke-dasharray: 5 5; stroke: #c8bba8; }
.tcard { position: absolute; background: #fff; border: 1px solid var(--line-strong); border-left: 6px solid var(--bc, #95a5a6); border-radius: 10px; padding: 8px 10px; display: flex; flex-direction: column; justify-content: center; box-shadow: var(--shadow); cursor: default; }
.tcard.focal { box-shadow: 0 0 0 3px #e2a54a, var(--shadow); }
.tc-name { font: 600 1rem/1.2 var(--serif); color: var(--ink); text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tc-name:hover { color: var(--accent); text-decoration: underline; }
.tc-dates { font-size: .85rem; color: var(--muted); }
.tc-open { font-size: .78rem; text-decoration: none; }
.tcard.ghost { border-style: dashed; border-left-width: 1px; background: rgba(255, 255, 255, .6); color: var(--muted); align-items: center; text-align: center; text-decoration: none; }
a.tcard.ghost:hover { border-color: var(--accent); color: var(--accent); }
.isolated { margin-top: 10px; }
.isolated summary { cursor: pointer; color: var(--muted); }

/* ----- Administration ----- */
.tabs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 16px; border-bottom: 2px solid var(--line); }
.tabs a { padding: 10px 16px; text-decoration: none; color: var(--ink); border-radius: 10px 10px 0 0; font-weight: 500; }
.tabs a.on { background: var(--paper); border: 2px solid var(--line); border-bottom-color: var(--paper); margin-bottom: -2px; }
.admin-body .card { margin-bottom: 16px; }
.admin-body h2 { margin-top: 0; }
.requests { display: flex; flex-direction: column; gap: 12px; }
.request { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; padding: 14px; border: 1px solid #ecd697; background: #fffbea; border-radius: 10px; }
.request blockquote { margin: 8px 0 0; padding: 6px 12px; border-left: 3px solid #ecd697; font-style: italic; }
.request-actions { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.trash, .tpl-admin { list-style: none; padding: 0; }
.trash li, .tpl-admin li { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); }
.tpl-admin li > span:last-child, .trash li > span:last-child { display: flex; gap: 6px; flex-wrap: wrap; }
.backup-row { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; }
.backup-row .hint { flex: 1; min-width: 240px; }

/* ----- Écrans moyens et petits ----- */
@media (max-width: 1100px) {
  .note-grid, .home-grid { grid-template-columns: minmax(0, 1fr); }
  .note-side { position: static; }
}
@media (max-width: 860px) {
  .burger { display: block; }
  .sidebar { position: fixed; left: 0; top: var(--top); z-index: 880; transform: translateX(-100%); transition: transform .2s; box-shadow: 4px 0 20px rgba(0, 0, 0, .2); }
  body.nav-open .sidebar { transform: none; }
  body.nav-open .nav-backdrop { display: block; position: fixed; inset: var(--top) 0 0; background: rgba(0, 0, 0, .3); z-index: 870; }
  .brand-txt { display: none; }
  .new-btn span { display: none; }
  .um-name { display: none; }
  .map-page { grid-template-columns: 1fr; grid-template-rows: auto 70vh; height: auto; }
  .map-panel { border-right: 0; border-bottom: 1px solid var(--line); order: 2; }
  .big-map { order: 1; height: 70vh; }
  .toolbar { position: static; }
  .tb-btn { height: 34px; padding: 0 7px; }
  .tb-wide { font-size: .82rem; }
  .tb-sep { display: none; }
  .edit-bar { padding: 6px 0; }
  .main { padding-top: 16px; }
  h1 { font-size: 1.6rem; }
  .tree-page { height: calc(100vh - var(--top)); }
}
@media (max-width: 520px) {
  .rt, .co-body, .note-body { overflow-wrap: anywhere; }
  .callout { padding: 10px 12px; }
  body { font-size: 16px; }
  .topbar { gap: 8px; padding: 0 8px; }
  .eb-ctls .eb-ctl { min-width: 30px; }
  .quick-add { grid-template-columns: 1fr; }
  .modal-overlay { padding: 2vh 6px; }
  .edit-bar-right .btn { padding: 8px 12px; }
}
@media print {
  .topbar, .sidebar, .note-actions, .note-side, .edit-bar, .toolbar { display: none !important; }
  .main { padding: 0; }
  .note-grid { display: block; }
  body { background: #fff; }
}
