/* ---------- Polices locales ---------- */
@font-face{font-family:"IBM Plex Sans";font-weight:400;font-display:swap;src:url(fonts/ibm-plex-sans-latin-400-normal.woff2) format("woff2")}
@font-face{font-family:"IBM Plex Sans";font-weight:500;font-display:swap;src:url(fonts/ibm-plex-sans-latin-500-normal.woff2) format("woff2")}
@font-face{font-family:"IBM Plex Sans";font-weight:600;font-display:swap;src:url(fonts/ibm-plex-sans-latin-600-normal.woff2) format("woff2")}
@font-face{font-family:"IBM Plex Mono";font-weight:400;font-display:swap;src:url(fonts/ibm-plex-mono-latin-400-normal.woff2) format("woff2")}
@font-face{font-family:"IBM Plex Mono";font-weight:500;font-display:swap;src:url(fonts/ibm-plex-mono-latin-500-normal.woff2) format("woff2")}
@font-face{font-family:"Literata";font-weight:400;font-style:normal;font-display:swap;src:url(fonts/literata-latin-400-normal.woff2) format("woff2")}
@font-face{font-family:"Literata";font-weight:400;font-style:italic;font-display:swap;src:url(fonts/literata-latin-400-italic.woff2) format("woff2")}
@font-face{font-family:"Literata";font-weight:600;font-style:normal;font-display:swap;src:url(fonts/literata-latin-600-normal.woff2) format("woff2")}

/* ---------- Thèmes ---------- */
:root{
  --bg:#ECEFEE; --surface:#FFFFFF; --side:#F4F6F5; --ink:#1C2826; --muted:#5D6E6B; --line:#D2DBD9; --hover:#E1E8E6; --code:#EFF3F2;
  --find:#FFE066; --find-cur:#FFA94D;
  --accent:#4357C8; --accent-soft:color-mix(in srgb, var(--accent) 14%, transparent);
  --hl-kw:#8B2FC9; --hl-str:#0E7A55; --hl-num:#B45309; --hl-com:#7A8794; --hl-fn:#2459C9; --hl-type:#B4235E; --hl-attr:#0F6C8C; --hl-del:#C0392B;
  --fs:16px;
  --ui:"IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono:"IBM Plex Mono", ui-monospace, Consolas, monospace;
  --serif:"Literata", Georgia, "Times New Roman", serif;
  --edfont:var(--ui); --edlh:1.65; --prose:var(--ui);
  color-scheme:light;
}
:root[data-font="serif"]{--edfont:var(--serif); --edlh:1.75; --prose:var(--serif)}
:root[data-font="mono"]{--edfont:var(--mono); --edlh:1.6; --prose:var(--ui)}
@media (prefers-color-scheme:dark){
  :root:not([data-theme="light"]){
    --bg:#141A19; --surface:#1B2322; --side:#172020; --ink:#E2EAE8; --muted:#8C9E9A; --line:#2B3735; --hover:#25302F; --code:#222C2B;
    --accent:#8C9BFF; --find:rgba(255,212,59,.45); --find-cur:rgba(255,146,43,.8);
    --hl-kw:#C792EA; --hl-str:#8FD694; --hl-num:#F5B76B; --hl-com:#7E8C99; --hl-fn:#82AAFF; --hl-type:#F78C9B; --hl-attr:#7FD3E6; --hl-del:#FF8A80;
    color-scheme:dark;
  }
}
:root[data-theme="dark"]{
  --bg:#141A19; --surface:#1B2322; --side:#172020; --ink:#E2EAE8; --muted:#8C9E9A; --line:#2B3735; --hover:#25302F; --code:#222C2B;
  --accent:#8C9BFF; --find:rgba(255,212,59,.45); --find-cur:rgba(255,146,43,.8);
  --hl-kw:#C792EA; --hl-str:#8FD694; --hl-num:#F5B76B; --hl-com:#7E8C99; --hl-fn:#82AAFF; --hl-type:#F78C9B; --hl-attr:#7FD3E6; --hl-del:#FF8A80;
  color-scheme:dark;
}

*{box-sizing:border-box}
html,body{height:100%;margin:0}
body{display:flex;background:var(--bg);color:var(--ink);font:14px/1.4 var(--ui);overflow:hidden}
button,input{font:inherit;color:inherit}
:focus-visible{outline:2px solid var(--accent);outline-offset:1px}
[hidden]{display:none!important}
.spacer{flex:1}
.muted{color:var(--muted)}

/* ---------- Boutons ---------- */
.btn{border:1px solid transparent;background:none;padding:5px 8px;border-radius:6px;cursor:pointer;white-space:nowrap}
.btn:hover{background:var(--hover)}
.btn.sm{padding:3px 7px;font-size:13px}
.btn:disabled{opacity:.45;cursor:not-allowed}
.btn.primary{background:var(--accent);color:#fff}
.btn.primary:hover{background:color-mix(in srgb, var(--accent) 85%, #000)}
.btn[aria-pressed="true"]{background:var(--hover);border-color:var(--line);box-shadow:inset 0 -2px 0 var(--accent)}
#install{border-color:var(--accent);color:var(--accent)}

/* ---------- Classeur ---------- */
.binder{position:relative;width:var(--binder-w,270px);flex:none;display:flex;flex-direction:column;background:var(--side);border-right:1px solid var(--line);min-height:0}
body.no-binder .binder{display:none}
.binder-head{display:flex;align-items:center;gap:4px;padding:10px 8px 4px 14px}
.binder-actions{display:flex;gap:2px;padding:2px 8px 8px;border-bottom:1px solid var(--line)}
.brand{font-weight:600;font-size:15px;color:var(--accent);letter-spacing:.01em}
.tree,.tree ul{list-style:none;margin:0;padding:0}
.tree{flex:1;overflow:auto;padding:6px}
.tree ul{padding-left:14px}
.row{display:flex;align-items:center;gap:6px;padding:4px 6px;border-radius:6px;cursor:pointer;user-select:none;min-height:30px}
.row:hover{background:var(--hover)}
.row.sel{background:var(--accent-soft)}
.row.open .t{font-weight:600}
.row .chev{width:16px;height:18px;flex:none;border:0;background:none;padding:0;border-radius:3px;color:var(--muted);font-size:11px;line-height:18px;text-align:center;transition:transform .15s}
button.chev{cursor:pointer}
button.chev:hover{color:var(--ink);background:var(--hover)}
.row.collapsed .chev{transform:rotate(-90deg)}
.row .ico{width:20px;height:20px;flex:none;display:flex;align-items:center;justify-content:center;color:var(--muted);border:0;background:none;padding:0;border-radius:5px}
.row .ico .ic{width:16px;height:16px}
.row.folder .ico{color:var(--accent);cursor:pointer}
.row.folder .ico .ic{width:17px;height:17px;stroke-width:2.1}
.row.folder button.ico:hover{background:var(--surface);box-shadow:0 0 0 1px var(--line)}
.row.folder .t{font-weight:500}
.row .t{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.row .w{flex:none;font-size:11px;color:var(--muted);font-variant-numeric:tabular-nums}
.row .del,.row .ren,.row .sort{flex:none;border:0;background:none;width:22px;height:22px;border-radius:4px;opacity:0;cursor:pointer;color:var(--muted);padding:0}
.row .del,.row .ren,.row .sort{display:none}
.row:hover .del,.row:hover .ren,.row:hover .sort,.row:focus-visible .del,.row:focus-visible .ren,.row:focus-visible .sort{display:block;opacity:.7}
.row .sort{font-size:10px;width:24px;font-weight:600}
.row .sort:hover{opacity:1;background:var(--hover);color:var(--accent)}
@media (hover:none){.row.sel .del,.row.sel .ren,.row.sel .sort{display:block;opacity:.7}.row.sel .w{display:none}}
.row .del:hover{opacity:1;background:var(--hover);color:#C2410C}
.row .ren:hover{opacity:1;background:var(--hover);color:var(--accent)}
.row:hover .w,.row:focus-visible .w{display:none}
.row input{flex:1;min-width:0;padding:1px 4px;border:1px solid var(--line);border-radius:4px;background:var(--surface)}
.row.drop-before{box-shadow:inset 0 2px 0 var(--accent)}
.row.drop-after{box-shadow:inset 0 -2px 0 var(--accent)}
.row.drop-inside{outline:2px dashed var(--accent);outline-offset:-2px}
.row.dragging{opacity:.4}
.binder-foot{display:flex;align-items:center;justify-content:space-between;gap:6px;padding:6px 8px 6px 14px;border-top:1px solid var(--line);font-size:12px;color:var(--muted)}
#accountBtn{color:var(--accent);max-width:150px;overflow:hidden;text-overflow:ellipsis}
#accountBtn.warn{color:#C2410C}

/* ---------- Espace de travail ---------- */
.workspace{flex:1;min-width:0;display:flex;flex-direction:column}
.toolbar,.findbar{display:flex;flex-wrap:wrap;align-items:center;gap:2px;padding:6px 10px;background:var(--surface);border-bottom:1px solid var(--line)}
.findbar{gap:6px}
.sep{width:1px;height:20px;background:var(--line);margin:0 6px}
.doc-title{font-weight:600;max-width:260px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;padding:4px 6px;border:0;background:none;border-radius:6px;cursor:text}
.doc-title:hover{background:var(--hover)}
.menu-left{left:0;right:auto}
.menu-sep{height:1px;background:var(--line);margin:4px 6px}
.menu-title{padding:4px 9px 0;font-size:11px;font-weight:600;letter-spacing:.06em;text-transform:uppercase;color:var(--muted)}
.menu-row select{font:inherit;padding:3px 6px;border:1px solid var(--line);border-radius:6px;background:var(--bg);color:var(--ink)}
.kbd{float:right;margin-left:16px;font-size:11px;color:var(--muted)}
.findbar input[type=text]{width:200px;padding:5px 8px;border:1px solid var(--line);border-radius:6px;background:var(--bg)}
.findbar label{display:flex;align-items:center;gap:5px;color:var(--muted)}
#findInfo{color:var(--muted);min-width:90px}
.menu-wrap{position:relative}
.menu{position:absolute;right:0;top:calc(100% + 4px);z-index:20;display:flex;flex-direction:column;gap:2px;min-width:270px;width:max-content;max-width:90vw;padding:6px;
  background:var(--surface);border:1px solid var(--line);border-radius:8px;box-shadow:0 10px 30px rgb(0 0 0 / .18)}
.menu > .btn{text-align:left}
.menu-hint{max-width:340px;padding:2px 9px 4px;font-size:12px;color:var(--muted);white-space:normal}
.binder.dropping .tree{outline:2px dashed var(--accent);outline-offset:-6px;border-radius:10px;background:var(--accent-soft)}
.menu-row{display:flex;align-items:center;gap:4px;padding:2px 2px 2px 9px}

.rowwrap{flex:1;min-height:0;display:flex}
main{flex:1;min-width:0;min-height:0;display:grid;grid-template-columns:minmax(0,var(--split,50%)) minmax(0,1fr);background:var(--surface);position:relative}
main[data-mode="edit"],main[data-mode="preview"]{grid-template-columns:1fr}
main[data-mode="edit"] #preview,main[data-mode="preview"] .edwrap{display:none}
main.empty .edwrap,main.empty #preview{display:none}
/* Dépôt de fichiers sur la note */
.drop-hint{display:none}
main.dropping .drop-hint{display:flex;position:absolute;inset:10px;z-index:4;align-items:center;justify-content:center;pointer-events:none;
  border:2px dashed var(--accent);border-radius:10px;background:color-mix(in srgb, var(--surface) 80%, transparent);color:var(--accent);font-weight:600;font-size:16px}
.empty-state{grid-column:1/-1;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:10px;color:var(--muted)}

.edwrap{position:relative;display:flex;flex-direction:column;min-width:0;min-height:0;overflow:hidden}
.edwrap > .cm-editor{flex:1;min-height:0}
main[data-mode="split"] .edwrap{border-right:1px solid var(--line)}
/* Poignée entre le texte et l'aperçu */
.splitter{display:none;position:absolute;top:0;bottom:0;left:var(--split,50%);width:11px;margin-left:-5px;z-index:3;cursor:col-resize;touch-action:none}
main[data-mode="split"]:not(.empty) .splitter{display:block}
.splitter::after{content:"";position:absolute;top:0;bottom:0;left:5px;width:1px;background:transparent;transition:background .15s,width .15s,left .15s}
.splitter:hover::after,.splitter:focus-visible::after,.splitter.drag::after{left:4px;width:3px;background:var(--accent)}
.splitter:focus-visible{outline:0}
body.resizing,body.resizing *{cursor:col-resize!important;user-select:none!important}
body.resizing #preview,body.resizing .cm-editor{pointer-events:none}
/* Poignée de largeur du classeur */
.binder-resize{position:absolute;top:0;bottom:0;right:-5px;width:10px;z-index:6;cursor:col-resize;touch-action:none}
.binder-resize::after{content:"";position:absolute;top:0;bottom:0;left:4px;width:2px;background:transparent;transition:background .15s}
.binder-resize:hover::after,.binder-resize:focus-visible::after,.binder-resize.drag::after{background:var(--accent)}
.binder-resize:focus-visible{outline:0}
.hide-binder{font-size:16px;line-height:1;padding:2px 8px;color:var(--muted)}
.hide-binder:hover{color:var(--accent)}
body.no-binder #toggleBinder{color:var(--accent);border-color:var(--line)}

/* ---------- Éditeur : rendu en direct ---------- */
.cm-editor .cm-content{max-width:none}
.cm-line.cm-lp-h{font-family:var(--prose);font-weight:650;line-height:1.3;color:var(--ink)}
.cm-line.cm-lp-h1{font-size:1.75em;padding-top:.45em;padding-bottom:.15em}
.cm-line.cm-lp-h2{font-size:1.4em;padding-top:.4em;padding-bottom:.1em}
.cm-line.cm-lp-h3{font-size:1.18em;padding-top:.3em}
.cm-line.cm-lp-h4,.cm-line.cm-lp-h5,.cm-line.cm-lp-h6{font-size:1.05em;padding-top:.2em}
.cm-line.cm-lp-h *{color:inherit}
.cm-lp-em{font-style:italic}
.cm-lp-strong{font-weight:700}
.cm-lp-strike{text-decoration:line-through;color:var(--muted)}
.cm-lp-code{font-family:var(--mono);font-size:.86em;background:var(--code);padding:.1em .3em;border-radius:4px}
.cm-lp-link,.cm-lp-link *{color:var(--accent);text-decoration:underline;text-decoration-color:color-mix(in srgb, var(--accent) 45%, transparent);text-underline-offset:2px}
.cm-lp-done{color:var(--muted);text-decoration:line-through;text-decoration-color:color-mix(in srgb, var(--muted) 60%, transparent)}
.cm-lp-check{width:1.05em;height:1.05em;margin:0 .35em 0 0;vertical-align:-.15em;accent-color:var(--accent);cursor:pointer}
.cm-lp-bullet{display:inline-block;width:1ch;margin-right:.1ch;color:var(--accent);font-weight:700;text-align:center}
.cm-line.cm-lp-quote{margin-left:28px;padding-left:calc(.8em - 3px);border-left:3px solid var(--accent);color:var(--muted);font-style:italic}
.cm-lp-hr{display:inline-block;width:100%;height:0;border-top:2px solid var(--line);vertical-align:middle}
.cm-line.cm-lp-codeblock{font-family:var(--mono);font-size:.88em;line-height:1.55;background:var(--code)}
.cm-line.cm-lp-fence{color:var(--muted);font-size:.78em}
.cm-line.cm-lp-tableraw{font-family:var(--mono);font-size:.88em}
.cm-lp-table{padding:4px 28px;font-size:.95em;cursor:text;white-space:normal;line-height:1.5}
.cm-lp-table table{margin:.2em 0}
.cm-lp-imgwrap{display:inline-block;max-width:100%;vertical-align:top}
.cm-lp-img{display:block;max-width:100%;max-height:55vh;margin:.3em 0;border-radius:4px;box-shadow:0 2px 10px rgb(0 0 0 / .1)}
.cm-lp-img.wait{width:220px;height:120px;background:var(--code);border:1px dashed var(--line)}
.cm-lp-missing{color:#C2410C;font-size:.9em}
.cm-lp-file{display:inline-flex;align-items:center;gap:10px;max-width:100%;margin:.2em 0;padding:6px 14px 6px 9px;vertical-align:middle;
  border:1px solid var(--line);border-radius:8px;background:var(--surface);font-family:var(--ui);line-height:1.3;cursor:pointer}
.cm-lp-file:hover{border-color:var(--accent);background:var(--accent-soft)}
.cm-lp-file .file-ico{flex:none;width:28px;height:36px}
.cm-lp-file.gone{border-style:dashed;color:#C2410C}
.cm-find{background:var(--find);border-radius:2px}
.cm-find-cur{background:var(--find-cur)}

/* ---------- Aperçu et texte de version ---------- */
#preview{overflow:auto;padding:22px 32px 60px}
#preview,.prose{font-size:var(--fs);line-height:1.7;font-family:var(--prose)}

#preview .empty{color:var(--muted)}
.prose h1,.prose h2,.prose h3,.prose h4{line-height:1.25;margin:1.4em 0 .5em;font-weight:600}
.prose h1{font-size:1.75em;margin-top:.3em}
.prose h2{font-size:1.4em}
.prose h3{font-size:1.15em}
.prose p,.prose ul,.prose ol,.prose pre,.prose blockquote,.prose table{margin:0 0 1em}
.prose a{color:var(--accent)}
.prose code{font-family:var(--mono);font-size:.85em;background:var(--code);padding:.12em .35em;border-radius:4px}
.prose pre{background:var(--code);padding:12px 14px;border-radius:6px;overflow:auto;line-height:1.5}
.prose pre code{background:none;padding:0}
.prose pre.numbered{display:grid;grid-template-columns:auto 1fr;column-gap:12px}
.prose pre .ln{font-family:var(--mono);font-size:.85em;text-align:right;white-space:pre;color:var(--muted);opacity:.6;user-select:none;padding-right:10px;border-right:1px solid var(--line)}
.prose blockquote{margin-left:0;padding:.2em 1em;border-left:3px solid var(--accent);color:var(--muted)}
.prose table{border-collapse:collapse;display:block;overflow-x:auto}
.prose th,.prose td{border:1px solid var(--line);padding:6px 10px;text-align:left}
.prose th{background:var(--code)}
.prose hr{border:0;text-align:center;margin:2em 0}
.prose hr::after{content:"* * *";color:var(--muted);letter-spacing:.4em}
.prose img{max-width:100%}
#preview > *,.prose > *{max-width:80ch}
.prose img.res-img{display:block;max-height:70vh;margin:.4em 0;border-radius:4px;cursor:zoom-in}
.prose img.res-wait{display:inline-block;width:220px;height:120px;background:var(--code);border:1px dashed var(--line);cursor:progress}
.prose a.res-card{display:inline-flex;align-items:center;gap:10px;max-width:100%;margin:.25em 0;padding:7px 14px 7px 9px;vertical-align:middle;
  text-decoration:none;color:var(--ink);border:1px solid var(--line);border-radius:8px;background:var(--surface);font-family:var(--ui);line-height:1.3;cursor:pointer}
.prose a.res-card:hover{border-color:var(--accent);background:var(--accent-soft)}
.prose a.res-card .file-ico{flex:none;width:30px;height:38px}
.prose a.res-card:hover .file-ico{transform:translateY(-1px)}
.res-txt{display:flex;flex-direction:column;min-width:0}
.res-name{font-size:.88em;font-weight:500;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.res-meta{font-size:.72em;color:var(--muted)}
.prose a.res-card.gone{border-style:dashed;color:#C2410C}
.prose .res-missing{color:#C2410C;font-size:.9em}
.prose li.task{list-style:none;margin-left:-1.3em}
.prose li.task > input,.prose li.task > p > input{width:1.05em;height:1.05em;margin:0 .45em 0 0;vertical-align:-.12em;accent-color:var(--accent);cursor:pointer}
.prose li.task.done{color:var(--muted);text-decoration:line-through;text-decoration-color:color-mix(in srgb, var(--muted) 60%, transparent)}

.hljs-keyword,.hljs-selector-tag,.hljs-literal,.hljs-doctag{color:var(--hl-kw)}
.hljs-string,.hljs-regexp,.hljs-addition,.hljs-selector-attr{color:var(--hl-str)}
.hljs-number,.hljs-symbol,.hljs-bullet,.hljs-link{color:var(--hl-num)}
.hljs-comment,.hljs-quote{color:var(--hl-com);font-style:italic}
.hljs-title,.hljs-section,.hljs-built_in,.hljs-title.function_{color:var(--hl-fn)}
.hljs-type,.hljs-title.class_,.hljs-tag,.hljs-name,.hljs-selector-id,.hljs-selector-class{color:var(--hl-type)}
.hljs-attr,.hljs-attribute,.hljs-variable,.hljs-template-variable,.hljs-property,.hljs-params{color:var(--hl-attr)}
.hljs-meta{color:var(--hl-com)}
.hljs-deletion{color:var(--hl-del)}

/* ---------- Panneau des versions ---------- */
.history{width:320px;flex:none;display:flex;flex-direction:column;background:var(--side);border-left:1px solid var(--line);min-height:0}
.history-head{display:flex;align-items:center;gap:4px;padding:10px 8px 8px 14px;border-bottom:1px solid var(--line)}
.history-note{margin:0;padding:8px 14px;font-size:12px;color:var(--muted);border-bottom:1px solid var(--line)}
#verList{list-style:none;margin:0;padding:6px;overflow:auto;flex:1}
.ver{display:block;width:100%;text-align:left;border:0;background:none;padding:7px 10px;border-radius:6px;cursor:pointer}
.ver:hover{background:var(--hover)}
.ver .vd{font-weight:500}
.ver .vm{font-size:12px;color:var(--muted);display:flex;gap:8px;margin-top:1px}
.ver .tag{font-size:11px;padding:0 6px;border-radius:9px;background:var(--accent-soft);color:var(--accent)}
.ver .plus{color:#0E7A55}.ver .minus{color:#C2410C}
.ver-empty{padding:10px;color:var(--muted);font-size:13px}
.ver .tag.warn,.tag.warn{font-size:11px;padding:0 6px;border-radius:9px;background:color-mix(in srgb, #C2410C 14%, transparent);color:#C2410C}
/* ---------- Panneau des pièces jointes ---------- */
#attInfo:empty{display:none}
#attList{list-style:none;margin:0;padding:6px;overflow:auto;flex:1}
.att{display:flex;gap:10px;align-items:flex-start;padding:7px 8px;border-radius:6px}
.att:hover{background:var(--hover)}
.att-th{flex:none;width:52px;height:52px;border-radius:5px;background:var(--code);display:flex;align-items:center;justify-content:center;overflow:hidden;color:var(--muted);font-size:20px}
.att-th{cursor:pointer}
.att-th .file-ico{width:30px;height:38px}
.att-th:hover{outline:2px solid var(--accent);outline-offset:-2px}
.att-th img{width:100%;height:100%;object-fit:cover}
.att-info{flex:1;min-width:0}
.att-name{display:block;max-width:100%;border:0;background:none;padding:0;text-align:left;font-weight:500;cursor:pointer;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.att-name:hover{color:var(--accent);text-decoration:underline}
.att .vm{font-size:12px;color:var(--muted);display:flex;flex-wrap:wrap;gap:6px;margin-top:1px}
.att-acts{display:flex;gap:2px;margin-top:3px}
.att-acts .btn{padding:1px 7px;color:var(--muted)}
.att-acts .btn:hover{color:var(--accent)}
.att-acts [data-act="del"]:hover{color:#C2410C}

/* ---------- Dialogues ---------- */
dialog{padding:0;border:1px solid var(--line);border-radius:10px;background:var(--surface);color:var(--ink);box-shadow:0 18px 50px rgb(0 0 0 / .25)}
dialog::backdrop{background:rgb(10 15 15 / .4)}
#gsearch{width:min(680px,94vw);max-height:72vh;margin:10vh auto auto}
#gsearch[open]{display:flex;flex-direction:column}
#gq{width:100%;border:0;border-bottom:1px solid var(--line);padding:14px 16px;font-size:16px;background:transparent;outline:0}
#gInfo{padding:6px 16px;font-size:12px;color:var(--muted)}
#gResults{list-style:none;margin:0;padding:0 6px 8px;overflow:auto}
.gres{display:block;width:100%;text-align:left;border:0;background:none;padding:8px 10px;border-radius:6px;cursor:pointer}
.gres.on,.gres:hover{background:var(--hover)}
.gres-head{display:flex;gap:8px;align-items:center;font-weight:500}
.gres-line{color:var(--muted);font-weight:400;font-size:12px}
.gres-path{color:var(--muted);font-weight:400;font-size:12px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.gres-snip{display:block;margin-top:2px;font-size:13px;color:var(--muted);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
mark{background:var(--find);color:inherit;border-radius:2px}
.prose mark.find{background:var(--find);color:inherit}
.prose mark.find.cur{background:var(--find-cur)}
#verView{width:min(900px,94vw);height:84vh}
#verView[open]{display:flex;flex-direction:column}
.vv-head{display:flex;align-items:center;gap:6px;padding:12px 14px;border-bottom:1px solid var(--line)}
#vvMeta{font-size:12px}
#vvBody{flex:1;overflow:auto;padding:22px 32px}

/* ---------- Barre d'état ---------- */
.status{display:flex;flex-wrap:wrap;gap:18px;padding:4px 12px;font-size:12px;color:var(--muted);background:var(--bg);border-top:1px solid var(--line)}
#saved{margin-left:auto}
#saved.err{color:#C2410C;font-weight:500}
#net{color:#B7791F;font-weight:500}
.sync-ok{color:var(--accent)}
.sync-error,.sync-relogin{color:#C2410C;font-weight:500}
.sync-offline{color:#B7791F}

/* ---------- Compte ---------- */
#account{width:min(520px,94vw);max-height:90vh}
#installHelp{width:min(440px,94vw)}
.acc-head{display:flex;align-items:center;padding:12px 14px;border-bottom:1px solid var(--line)}
.acc-body{padding:14px 18px 16px;overflow:auto}
.acc-tabs{display:flex;flex-wrap:wrap;gap:2px;margin-bottom:12px}
.acc-form{display:flex;flex-direction:column;gap:10px}
.acc-form label{display:flex;flex-direction:column;gap:4px;font-weight:500}
.acc-form input{font-weight:400;padding:8px 10px;border:1px solid var(--line);border-radius:6px;background:var(--bg)}
.acc-form .btn.primary{align-self:flex-start;padding:7px 14px}
.acc-note{margin:0;font-size:13px;line-height:1.5;color:var(--muted)}
.acc-hint{margin:0;font-size:12px;color:var(--muted)}
.acc-row{display:flex;gap:6px;margin:10px 0}
.acc-msg{margin:10px 0 0;font-size:13px;color:var(--muted);min-height:1em}
.acc-msg.err{color:#C2410C;font-weight:500}
.kit-code{font:600 19px/1.6 var(--mono);letter-spacing:.04em;padding:12px 14px;margin:8px 0;border:2px dashed var(--accent);border-radius:8px;
  background:var(--accent-soft);white-space:pre-line;text-align:center;user-select:all}
.check{display:flex;align-items:center;gap:8px;margin:10px 0}
#accKit .btn.primary{padding:7px 14px}
.meter{height:8px;border-radius:4px;background:var(--hover);overflow:hidden;margin:6px 0 4px}
#accMeter{height:100%;width:0;background:var(--accent)}
#account details{margin:10px 0;border-top:1px solid var(--line);padding-top:10px}
#account summary{cursor:pointer;font-weight:500;margin-bottom:8px}
#account details.danger summary{color:#C2410C}
.danger-btn{background:#C2410C;color:#fff;align-self:flex-start;padding:7px 14px}

/* ---------- Mode focus ---------- */
.exit-focus{display:none}
body.focus .binder,body.focus .toolbar,body.focus .status,body.focus .history{display:none!important}
body.focus main{grid-template-columns:1fr}
body.focus main[data-mode="split"] #preview,body.focus .splitter{display:none!important}
body.focus main{grid-template-columns:1fr!important}
body.focus .cm-line{padding-left:max(24px, calc((100% - 80ch) / 2));padding-right:max(24px, calc((100% - 80ch) / 2))}
body.focus .cm-content{padding-top:8vh}
body.focus #preview{padding:8vh max(24px, calc((100% - 80ch) / 2)) 30vh}
body.focus .exit-focus{display:block;position:fixed;top:10px;right:14px;z-index:5;background:var(--surface);border-color:var(--line);color:var(--muted);opacity:.35;animation:hint 3s ease-out}
body.focus .exit-focus:hover,body.focus .exit-focus:focus-visible{opacity:1}
@keyframes hint{0%,60%{opacity:1}100%{opacity:.35}}

/* ---------- Petits écrans ---------- */
@media (max-width:820px){
  .binder{position:fixed;inset:0 auto 0 0;z-index:30;width:min(300px,85vw);box-shadow:0 0 40px rgb(0 0 0 / .25);display:none}
  body.binder-open .binder{display:flex}
  main[data-mode="split"]{grid-template-columns:1fr;grid-template-rows:1fr 1fr}
  .splitter,main[data-mode="split"]:not(.empty) .splitter,.binder-resize{display:none}
  main[data-mode="split"] .edwrap{border-right:0;border-bottom:1px solid var(--line)}
  .history{position:fixed;inset:0 0 0 auto;z-index:30;width:min(320px,90vw);box-shadow:0 0 40px rgb(0 0 0 / .25)}
  .cm-line{padding:0 16px}
}
@media (prefers-reduced-motion:reduce){.row .chev{transition:none}body.focus .exit-focus{animation:none}}

/* ---------- Impression ---------- */
@media print{
  :root{--ink:#000;--surface:#fff;--code:#f2f2f2;--line:#ccc}
  body{display:block;overflow:visible;background:#fff}
  .binder,.toolbar,.findbar,.status,.history,.exit-focus,.edwrap,.splitter{display:none!important}
  .workspace,.rowwrap,main{display:block}
  #preview{display:block!important;overflow:visible;padding:0}
}

/* ---------- Icônes ---------- */
.ic{width:18px;height:18px;flex:none;display:block}

/* ---------- Choix d'icône d'un dossier ---------- */
.icon-picker{position:fixed;z-index:60;width:min(352px,94vw);max-height:70vh;display:flex;flex-direction:column;background:var(--surface);border:1px solid var(--line);
  border-radius:12px;box-shadow:0 14px 40px rgb(0 0 0 / .22)}
.ip-head{display:flex;align-items:center;gap:4px;padding:10px 10px 6px 14px}
.ip-head strong{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.ip-colors{display:flex;flex-wrap:wrap;gap:7px;padding:4px 14px 10px;border-bottom:1px solid var(--line)}
.ip-col{width:20px;height:20px;border-radius:50%;border:0;cursor:pointer;box-shadow:inset 0 0 0 1px rgb(0 0 0 / .12)}
.ip-col.on{box-shadow:0 0 0 2px var(--surface),0 0 0 4px var(--ink)}
.ip-icons{display:grid;grid-template-columns:repeat(8,1fr);gap:2px;padding:8px;overflow:auto}
.ip-ico{aspect-ratio:1;display:flex;align-items:center;justify-content:center;border:0;background:none;border-radius:7px;cursor:pointer}
.ip-ico:hover{background:var(--hover)}
.ip-ico.on{background:var(--accent-soft);box-shadow:inset 0 0 0 1.5px currentColor}
.ip-ico .ic{width:20px;height:20px}

/* ---------- Barre de mise en forme ---------- */
.fmtbar{position:absolute;left:50%;bottom:14px;transform:translateX(-50%);z-index:4;display:flex;align-items:center;gap:2px;padding:4px 6px;
  background:color-mix(in srgb, var(--side) 92%, transparent);backdrop-filter:blur(8px);border:1px solid var(--line);border-radius:12px;
  box-shadow:0 6px 24px rgb(0 0 0 / .10);max-width:calc(100% - 20px);overflow-x:auto;scrollbar-width:none}
main.empty .fmtbar{display:none}
.fmt-btn{display:flex;align-items:center;gap:1px;height:34px;min-width:36px;justify-content:center;padding:0 7px;border:0;background:none;border-radius:8px;color:var(--ink);cursor:pointer;opacity:.78}
.fmt-btn:hover{background:var(--hover);opacity:1}
.fmt-btn.on,.fmt-btn[aria-expanded="true"]{background:var(--accent-soft);color:var(--accent);opacity:1}
.fmt-btn .ic{width:19px;height:19px}
.fmt-btn .ic.chev{width:12px;height:12px;opacity:.7}
.fmt-btn[data-menu="highlight"] .ic:first-child{color:#E5484D}
.fmt-sep{width:1px;height:20px;background:var(--line);margin:0 8px}
.fmt-menu{position:absolute;z-index:5;min-width:210px;padding:5px;display:flex;flex-direction:column;gap:1px;background:var(--surface);border:1px solid var(--line);
  border-radius:10px;box-shadow:0 12px 34px rgb(0 0 0 / .18)}
.fmt-menu.colors{display:grid;grid-template-columns:1fr 1fr;min-width:230px}
.fmt-item{display:flex;align-items:center;gap:10px;padding:7px 10px;border:0;background:none;border-radius:7px;cursor:pointer;text-align:left;white-space:nowrap}
.fmt-item:hover{background:var(--hover)}
.fmt-item .ic{width:17px;height:17px;color:var(--muted)}
.fmt-item .kbd{margin-left:auto;padding-left:14px;font-size:11px;color:var(--muted)}
.hl-swatch{display:inline-block;padding:0 5px;border-radius:4px;font-weight:600;font-size:13px}
body.focus .fmtbar{opacity:.25;transition:opacity .2s}
body.focus .fmtbar:hover,body.focus .fmtbar:focus-within{opacity:1}
@media (max-width:820px){.fmtbar{bottom:8px}.fmt-sep{margin:0 3px}.fmt-btn{min-width:32px;padding:0 5px}}

/* ---------- Surligneur ---------- */
.hl,.cm-lp-hl{border-radius:3px;padding:0 .12em;color:inherit;-webkit-box-decoration-break:clone;box-decoration-break:clone}
.hl-jaune{background:#FFE36E99}.hl-vert{background:#7BDCA699}.hl-bleu{background:#8EC8FF99}.hl-rouge{background:#FF9AA299}
.hl-violet{background:#D2A8FF99}.hl-orange{background:#FFB96B99}.hl-rose{background:#FFA8D899}.hl-gris{background:#C5C9D299}
:root[data-theme="dark"] .hl,:root[data-theme="dark"] .cm-lp-hl{color:#fff}
@media (prefers-color-scheme:dark){:root:not([data-theme="light"]) .hl,:root:not([data-theme="light"]) .cm-lp-hl{color:#fff}}
.prose mark.hl{color:inherit}
