/* Carnet — styles */

:root {
  --bg: #ffffff;
  --bg-side: #f7f7f5;
  --bg-hover: rgba(55, 53, 47, .06);
  --bg-active: rgba(55, 53, 47, .1);
  --bg-elev: #ffffff;
  --bg-code: #f7f6f3;
  --bg-input: rgba(242, 241, 238, .7);
  --text: #37352f;
  --text-2: rgba(55, 53, 47, .65);
  --text-3: rgba(55, 53, 47, .45);
  --border: rgba(55, 53, 47, .12);
  --border-strong: rgba(55, 53, 47, .2);
  --accent: #2383e2;
  --accent-bg: rgba(35, 131, 226, .14);
  --danger: #d44c47;
  --shadow: 0 0 0 1px rgba(15, 15, 15, .05), 0 3px 6px rgba(15, 15, 15, .1), 0 9px 24px rgba(15, 15, 15, .2);
  --radius: 6px;
  --font: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, "Apple Color Emoji", Arial, sans-serif, "Segoe UI Emoji", "Segoe UI Symbol";
  --mono: "SFMono-Regular", Menlo, Consolas, "Liberation Mono", "Courier New", monospace;
  --sidebar-w: 260px;

  /* couleurs sémantiques (texte / fond) */
  --c-gray: #787774;   --b-gray: #f1f1ef;
  --c-brown: #9f6b53;  --b-brown: #f4eeee;
  --c-orange: #d9730d; --b-orange: #fbecdd;
  --c-yellow: #cb912f; --b-yellow: #fbf3db;
  --c-green: #448361;  --b-green: #edf3ec;
  --c-blue: #337ea9;   --b-blue: #e7f3f8;
  --c-purple: #9065b0; --b-purple: #f6f3f9;
  --c-pink: #c14c8a;   --b-pink: #faf1f5;
  --c-red: #d44c47;    --b-red: #fdebec;

  --grad-0: linear-gradient(120deg, #f6d365 0%, #fda085 100%);
  --grad-1: linear-gradient(120deg, #84fab0 0%, #8fd3f4 100%);
  --grad-2: linear-gradient(120deg, #a1c4fd 0%, #c2e9fb 100%);
  --grad-3: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  --grad-4: linear-gradient(120deg, #fccb90 0%, #d57eeb 100%);
  --grad-5: linear-gradient(135deg, #0f2027 0%, #203a43 50%, #2c5364 100%);
  --grad-6: linear-gradient(120deg, #e0c3fc 0%, #8ec5fc 100%);
  --grad-7: linear-gradient(135deg, #43cea2 0%, #185a9d 100%);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #191919; --bg-side: #202020; --bg-hover: rgba(255, 255, 255, .055); --bg-active: rgba(255, 255, 255, .09);
    --bg-elev: #252525; --bg-code: #262626; --bg-input: rgba(255, 255, 255, .055);
    --text: #d4d4d4; --text-2: rgba(255, 255, 255, .56); --text-3: rgba(255, 255, 255, .34);
    --border: rgba(255, 255, 255, .09); --border-strong: rgba(255, 255, 255, .16);
    --shadow: 0 0 0 1px rgba(255, 255, 255, .07), 0 3px 6px rgba(0, 0, 0, .3), 0 9px 24px rgba(0, 0, 0, .5);
    --c-gray: #9b9b9b; --b-gray: #2f2f2f; --c-brown: #ba856f; --b-brown: #4a3228; --c-orange: #c77d48; --b-orange: #5c3b23;
    --c-yellow: #ca9849; --b-yellow: #564328; --c-green: #529e72; --b-green: #243d30; --c-blue: #5e87c9; --b-blue: #143a4e;
    --c-purple: #9d68d3; --b-purple: #3c2d49; --c-pink: #d15796; --b-pink: #4e2c3c; --c-red: #df5452; --b-red: #522e2a;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #191919; --bg-side: #202020; --bg-hover: rgba(255, 255, 255, .055); --bg-active: rgba(255, 255, 255, .09);
  --bg-elev: #252525; --bg-code: #262626; --bg-input: rgba(255, 255, 255, .055);
  --text: #d4d4d4; --text-2: rgba(255, 255, 255, .56); --text-3: rgba(255, 255, 255, .34);
  --border: rgba(255, 255, 255, .09); --border-strong: rgba(255, 255, 255, .16);
  --shadow: 0 0 0 1px rgba(255, 255, 255, .07), 0 3px 6px rgba(0, 0, 0, .3), 0 9px 24px rgba(0, 0, 0, .5);
  --c-gray: #9b9b9b; --b-gray: #2f2f2f; --c-brown: #ba856f; --b-brown: #4a3228; --c-orange: #c77d48; --b-orange: #5c3b23;
  --c-yellow: #ca9849; --b-yellow: #564328; --c-green: #529e72; --b-green: #243d30; --c-blue: #5e87c9; --b-blue: #143a4e;
  --c-purple: #9d68d3; --b-purple: #3c2d49; --c-pink: #d15796; --b-pink: #4e2c3c; --c-red: #df5452; --b-red: #522e2a;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--text); font: 16px/1.5 var(--font); -webkit-font-smoothing: antialiased; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
input, select { font: inherit; color: inherit; }
a { color: inherit; }
kbd { font: 11px var(--font); color: var(--text-3); margin-left: auto; }
[hidden] { display: none !important; }
.muted { color: var(--text-2); }
.small { font-size: 13px; }
.spacer { flex: 1; }
.row { display: flex; align-items: center; }
.gap { gap: 8px; }
.stack { display: flex; flex-direction: column; gap: 8px; }

.ico { display: inline-flex; width: 18px; height: 18px; flex: none; }
.ico svg, .icon-btn svg, .ti-arrow svg, .blk-handle svg, .blk-plus svg, .blk-toggle svg, .pg-icon svg, .url-open svg {
  width: 100%; height: 100%; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round;
}
svg.fill, .ico svg.fill { fill: currentColor; stroke: none; }

/* ---------- boutons & champs ---------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 32px; padding: 0 12px;
  border-radius: var(--radius); border: 1px solid var(--border-strong); background: var(--bg-elev); font-size: 14px; white-space: nowrap;
  transition: background .12s;
}
.btn:hover { background: var(--bg-hover); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 45%, transparent); }
.btn.danger:hover { background: color-mix(in srgb, var(--danger) 10%, transparent); }
.btn.small { height: 28px; font-size: 13px; padding: 0 10px; }
.btn.tiny { height: 22px; font-size: 12px; padding: 0 7px; }
.btn.wide { width: 100%; height: 38px; }
.btn.glass { background: rgba(255, 255, 255, .85); color: #37352f; border-color: transparent; }
.btn:disabled { opacity: .6; cursor: default; }
.input {
  width: 100%; height: 36px; padding: 0 10px; border-radius: var(--radius); border: 1px solid var(--border-strong);
  background: var(--bg-input); outline: none; font-size: 15px;
}
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-bg); }
.input.small { height: 30px; font-size: 14px; }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px; padding: 5px;
  border-radius: 5px; color: var(--text-2); flex: none;
}
.icon-btn:hover { background: var(--bg-hover); color: var(--text); }
.icon-btn.tiny { width: 22px; height: 22px; padding: 3px; }
.icon-btn.fav { color: #e5a82d; }
.icon-btn.fav svg { fill: currentColor; }
.ghost-btn { color: var(--text-3); font-size: 14px; padding: 4px 8px; border-radius: 5px; }
.ghost-btn:hover { background: var(--bg-hover); color: var(--text-2); }

/* ---------- authentification ---------- */

.boot-loader { position: fixed; inset: 0; display: grid; place-items: center; }
.auth { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 24px; background: var(--bg-side); }
.auth-card { width: min(360px, 100%); background: var(--bg); padding: 32px; border-radius: 12px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 12px; text-align: center; }
.auth-card h1 { margin: 0; font-size: 26px; }
.auth-card p { margin: 0 0 8px; font-size: 14px; }
.auth-logo { width: 44px; height: 44px; margin: 0 auto; }
.auth-error { color: var(--danger); font-size: 14px; min-height: 1em; }

/* ---------- structure ---------- */

.shell { display: flex; height: 100vh; height: 100dvh; overflow: hidden; }
.sidebar {
  width: var(--sidebar-w); flex: none; background: var(--bg-side); display: flex; flex-direction: column;
  border-right: 1px solid var(--border); font-size: 14px; color: var(--text-2); transition: margin-left .2s ease;
}
.resizer { width: 5px; margin-left: -3px; cursor: col-resize; flex: none; z-index: 5; }
.resizer:hover { background: var(--accent-bg); }
.shell.sidebar-hidden .sidebar { margin-left: calc(-1 * var(--sidebar-w)); }
.shell.sidebar-hidden .resizer { display: none; }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { height: 45px; flex: none; display: flex; align-items: center; gap: 6px; padding: 0 12px; }
.show-sidebar { display: none; }
.shell.sidebar-hidden .show-sidebar { display: inline-flex; }
.crumbs { display: flex; align-items: center; min-width: 0; overflow: hidden; font-size: 14px; }
.crumb { display: flex; align-items: center; gap: 4px; padding: 2px 6px; border-radius: 4px; min-width: 0; white-space: nowrap; }
.crumb:hover { background: var(--bg-hover); }
.crumb-title { overflow: hidden; text-overflow: ellipsis; max-width: 200px; }
.crumb-sep { color: var(--text-3); margin: 0 1px; }
.status { font-size: 13px; color: var(--text-3); white-space: nowrap; }
.status[data-state="error"] { color: var(--danger); }
.top-actions { display: flex; gap: 2px; }
.scroller { flex: 1; overflow-y: auto; overflow-x: hidden; position: relative; }
.sidebar-backdrop { display: none; }

/* ---------- barre latérale ---------- */

.sb-head { display: flex; align-items: center; padding: 10px 10px 6px 14px; }
.sb-brand { display: flex; align-items: center; gap: 8px; font-weight: 600; color: var(--text); flex: 1; }
.sb-brand img { width: 20px; height: 20px; }
.sb-actions, .sb-foot { padding: 2px 6px; display: flex; flex-direction: column; }
.sb-foot { border-top: 1px solid var(--border); padding-top: 6px; padding-bottom: 8px; }
.sb-btn { display: flex; align-items: center; gap: 8px; height: 30px; padding: 0 8px; border-radius: 5px; text-align: left; width: 100%; }
.sb-btn:hover { background: var(--bg-hover); color: var(--text); }
.sb-scroll { flex: 1; overflow-y: auto; padding: 8px 6px; }
.sb-section + .sb-section { margin-top: 14px; }
.sb-title { display: flex; align-items: center; justify-content: space-between; padding: 0 6px 0 10px; height: 26px; font-size: 12px; font-weight: 600; color: var(--text-3); }
.sb-title .icon-btn { opacity: 0; }
.sb-title:hover .icon-btn { opacity: 1; }
.sb-empty, .ti-none { font-size: 13px; color: var(--text-3); padding: 4px 12px; }
.ti { display: flex; align-items: center; gap: 4px; height: 30px; padding-right: 4px; border-radius: 5px; cursor: pointer; user-select: none; position: relative; }
.ti:hover { background: var(--bg-hover); }
.ti.active { background: var(--bg-active); color: var(--text); font-weight: 500; }
.ti.dragging { opacity: .4; }
.ti.drop-inside { background: var(--accent-bg); box-shadow: inset 0 0 0 1px var(--accent); }
.ti.drop-before::before, .ti.drop-after::after { content: ""; position: absolute; left: 8px; right: 4px; height: 2px; background: var(--accent); border-radius: 2px; }
.ti.drop-before::before { top: -1px; }
.ti.drop-after::after { bottom: -1px; }
.ti-arrow { width: 20px; height: 20px; padding: 3px; border-radius: 4px; color: var(--text-3); flex: none; transition: transform .15s; }
.ti-arrow:hover { background: var(--bg-active); }
.ti-arrow.open { transform: rotate(90deg); }
.ti-arrow.leaf { opacity: .45; }
.ti-title { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ti-actions { display: none; }
.ti:hover .ti-actions { display: flex; }
.pg-icon { display: inline-flex; align-items: center; justify-content: center; width: 20px; height: 20px; flex: none; color: var(--text-3); }
.pg-icon.emoji { font-size: 16px; line-height: 1; color: initial; }
.pg-icon:not(.emoji) svg { width: 18px; height: 18px; }

/* ---------- page ---------- */

.cover { height: 30vh; min-height: 160px; max-height: 280px; background-size: cover; background-position: center; position: relative; }
.cover-actions { position: absolute; right: 24px; bottom: 12px; opacity: 0; transition: opacity .15s; }
.cover:hover .cover-actions { opacity: 1; }
.page { max-width: 900px; margin: 0 auto; padding: 0 96px 30vh; }
.page.full { max-width: none; }
.page-head { padding-top: 80px; position: relative; }
.page-head.has-cover { padding-top: 24px; }
.page-head.has-cover.has-icon { padding-top: 0; }
.page-head.has-cover .page-icon { margin-top: -42px; }
.page-icon { font-size: 72px; line-height: 1; width: 84px; height: 84px; display: flex; align-items: center; justify-content: center; border-radius: 8px; position: relative; }
.page-icon:hover { background: var(--bg-hover); }
.page-controls { display: flex; gap: 4px; margin: 4px 0 4px -8px; opacity: 0; transition: opacity .15s; min-height: 30px; }
.page-head:hover .page-controls { opacity: 1; }
.page-title { font-size: 40px; font-weight: 700; line-height: 1.2; margin: 0 0 8px; outline: none; word-break: break-word; }
.page-title:empty::before { content: attr(data-ph); color: var(--text-3); }
.empty-state { text-align: center; padding: 18vh 24px; }
.empty-emoji { font-size: 64px; }
.empty-state .row { justify-content: center; margin-top: 16px; }

/* ---------- éditeur de blocs ---------- */

.editor { padding-top: 6px; }
.editor-tail { min-height: 120px; cursor: text; }
.editor-hint { color: var(--text-3); padding: 3px 2px; }
.blk { position: relative; padding-left: calc(var(--indent, 0) * 26px); margin: 1px 0; }
.blk-body { display: flex; align-items: flex-start; min-height: 30px; border-radius: 4px; }
.blk-text { flex: 1; min-width: 0; outline: none; padding: 3px 2px; white-space: pre-wrap; word-break: break-word; caret-color: var(--text); }
.blk-text:empty::before { content: attr(data-ph); color: var(--text-3); pointer-events: none; }
.t-paragraph .blk-text:not(:focus):empty::before { content: ""; }
.blk-gutter {
  position: absolute; top: 3px; left: calc(var(--indent, 0) * 26px - 50px); display: flex; gap: 1px;
  opacity: 0; transition: opacity .12s;
}
.blk:hover > .blk-gutter { opacity: 1; }
.blk-handle, .blk-plus { width: 24px; height: 24px; border-radius: 4px; color: var(--text-3); display: grid; place-items: center; }
.blk-handle { cursor: grab; width: 18px; }
.blk-handle svg { width: 10px; height: 16px; }
.blk-plus svg { width: 17px; height: 17px; }
.blk-handle:hover, .blk-plus:hover { background: var(--bg-hover); }
.blk.dragging { opacity: .35; }
.blk.drop-before::before, .blk.drop-after::after {
  content: ""; position: absolute; left: calc(var(--indent, 0) * 26px); right: 0; height: 3px; background: var(--accent); opacity: .6; border-radius: 2px;
}
.blk.drop-before::before { top: -2px; }
.blk.drop-after::after { bottom: -2px; }

.t-h1 { margin-top: 1.4em; } .t-h1 .blk-text { font-size: 1.875em; font-weight: 700; line-height: 1.3; }
.t-h2 { margin-top: 1.1em; } .t-h2 .blk-text { font-size: 1.5em; font-weight: 650; line-height: 1.3; }
.t-h3 { margin-top: .8em; }  .t-h3 .blk-text { font-size: 1.25em; font-weight: 600; line-height: 1.3; }
.t-h1 .blk-gutter { top: 9px; } .t-h2 .blk-gutter { top: 6px; } .t-h3 .blk-gutter { top: 4px; }

.blk-prefix { flex: none; width: 26px; min-height: 30px; display: flex; align-items: center; justify-content: center; }
.blk-prefix.bullet::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.blk-prefix.bullet[data-level="1"]::before { background: transparent; border: 1.5px solid currentColor; width: 5px; height: 5px; }
.blk-prefix.bullet[data-level="2"]::before { border-radius: 0; width: 5px; height: 5px; }
.blk-prefix.num { justify-content: flex-end; padding-right: 6px; width: auto; min-width: 26px; font-variant-numeric: tabular-nums; }
.blk-check {
  width: 16px; height: 16px; border: 1.5px solid var(--text-2); border-radius: 3px; display: grid; place-items: center; transition: background .1s;
}
.blk-check.on { background: var(--accent); border-color: var(--accent); }
.blk-check.on::after { content: ""; width: 9px; height: 5px; border: 2px solid #fff; border-top: 0; border-right: 0; transform: rotate(-45deg) translate(1px, -1px); }
.blk.checked .blk-text { color: var(--text-3); text-decoration: line-through; }
.blk-toggle { padding: 5px; color: var(--text-2); border-radius: 4px; transition: transform .15s; height: 26px; min-height: 0; margin-top: 2px; }
.blk-toggle:hover { background: var(--bg-hover); }
.blk-toggle.open { transform: rotate(90deg); }
.t-quote .blk-body { border-left: 3px solid currentColor; border-radius: 0; padding-left: 12px; margin: 4px 0; }
.t-quote .blk-text { font-size: 1.1em; }
.t-callout .blk-body { background: var(--b-gray); padding: 14px 14px 14px 10px; margin: 4px 0; border-radius: 6px; }
.blk-callout-icon { font-size: 20px; width: 30px; height: 30px; border-radius: 4px; flex: none; margin-right: 6px; }
.blk-callout-icon:hover { background: var(--bg-hover); }
.t-callout .blk-gutter { top: 17px; }
.t-code .blk-body { flex-direction: column; background: var(--bg-code); border-radius: 6px; margin: 4px 0; position: relative; }
.code-wrap { position: relative; width: 100%; }
.t-code .blk-text, .code-hl {
  font: 14px/1.6 var(--mono); padding: 32px 18px 18px; tab-size: 4; white-space: pre-wrap; overflow-wrap: anywhere;
  width: 100%; margin: 0; letter-spacing: normal; box-sizing: border-box;
}
.code-hl { position: absolute; inset: 0; pointer-events: none; overflow: hidden; color: var(--text); }
.t-code .blk-text { position: relative; }
.hl-on .blk-text { color: transparent; caret-color: var(--text); }
.hl-on .blk-text::selection { background: rgba(35, 131, 226, .28); color: transparent; }
.code-bar { position: absolute; top: 6px; left: 12px; right: 8px; display: flex; justify-content: space-between; opacity: 0; transition: opacity .15s; }
.t-code:hover .code-bar, .t-code:focus-within .code-bar { opacity: 1; }
.code-lang { max-width: 180px; background: transparent; border: 0; color: var(--text-2); font-size: 12px; padding: 2px; border-radius: 4px; cursor: pointer; }
.code-lang:hover { background: var(--bg-hover); }
.t-divider .blk-body { align-items: center; min-height: 26px; }
.t-divider hr { flex: 1; border: 0; border-top: 1px solid var(--border-strong); margin: 0; }
.blk-figure { margin: 6px 0; width: 100%; display: flex; flex-direction: column; align-items: center; }
.blk-figure img { max-width: 100%; border-radius: 4px; display: block; }
.blk-figure .blk-text { width: 100%; text-align: center; font-size: 14px; color: var(--text-2); }
.t-image .blk-text:empty:not(:focus)::before { content: ""; }
.img-empty { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; width: 100%; padding: 14px; background: var(--bg-hover); border-radius: 6px; color: var(--text-2); margin: 4px 0; }
.blk-page { display: flex; align-items: center; gap: 6px; padding: 3px 4px; border-radius: 4px; text-decoration: none; width: 100%; font-weight: 500; }
.blk-page:hover { background: var(--bg-hover); }
.blk-page .blk-page-title { border-bottom: 1px solid var(--border-strong); }
.blk-page.missing { color: var(--text-3); font-style: italic; font-weight: 400; }

/* Mise en forme inline */
.blk-text code, .search-snip code {
  font-family: var(--mono); font-size: 85%; background: var(--bg-code); color: #eb5757; padding: .15em .35em; border-radius: 4px;
}
.t-code .blk-text code { background: none; color: inherit; padding: 0; }
.blk-text a { color: inherit; text-decoration: underline; text-decoration-color: var(--text-3); text-underline-offset: 2px; cursor: pointer; }
.blk-text a:hover { text-decoration-color: currentColor; }
.c-gray { color: var(--c-gray); } .c-brown { color: var(--c-brown); } .c-orange { color: var(--c-orange); }
.c-yellow { color: var(--c-yellow); } .c-green { color: var(--c-green); } .c-blue { color: var(--c-blue); }
.c-purple { color: var(--c-purple); } .c-pink { color: var(--c-pink); } .c-red { color: var(--c-red); }
.bg-gray { background: var(--b-gray); } .bg-brown { background: var(--b-brown); } .bg-orange { background: var(--b-orange); }
.bg-yellow { background: var(--b-yellow); } .bg-green { background: var(--b-green); } .bg-blue { background: var(--b-blue); }
.bg-purple { background: var(--b-purple); } .bg-pink { background: var(--b-pink); } .bg-red { background: var(--b-red); }
span[class^="bg-"] { border-radius: 3px; padding: 0 2px; }

/* Couleur d'un bloc entier */
.bc-gray .blk-text { color: var(--c-gray); } .bc-brown .blk-text { color: var(--c-brown); } .bc-orange .blk-text { color: var(--c-orange); }
.bc-yellow .blk-text { color: var(--c-yellow); } .bc-green .blk-text { color: var(--c-green); } .bc-blue .blk-text { color: var(--c-blue); }
.bc-purple .blk-text { color: var(--c-purple); } .bc-pink .blk-text { color: var(--c-pink); } .bc-red .blk-text { color: var(--c-red); }
.t-callout.bc-gray .blk-text, .t-callout.bc-brown .blk-text, .t-callout.bc-orange .blk-text, .t-callout.bc-yellow .blk-text,
.t-callout.bc-green .blk-text, .t-callout.bc-blue .blk-text, .t-callout.bc-purple .blk-text, .t-callout.bc-pink .blk-text,
.t-callout.bc-red .blk-text { color: inherit; }
.t-callout.bc-brown .blk-body { background: var(--b-brown); } .t-callout.bc-orange .blk-body { background: var(--b-orange); }
.t-callout.bc-yellow .blk-body { background: var(--b-yellow); } .t-callout.bc-green .blk-body { background: var(--b-green); }
.t-callout.bc-blue .blk-body { background: var(--b-blue); } .t-callout.bc-purple .blk-body { background: var(--b-purple); }
.t-callout.bc-pink .blk-body { background: var(--b-pink); } .t-callout.bc-red .blk-body { background: var(--b-red); }

/* ---------- barre de mise en forme ---------- */

.toolbar {
  position: fixed; z-index: 60; display: flex; padding: 3px; gap: 1px; background: var(--bg-elev);
  border-radius: 6px; box-shadow: var(--shadow);
}
.tb-btn { min-width: 30px; height: 28px; padding: 0 7px; border-radius: 4px; font-size: 14px; }
.tb-btn:hover { background: var(--bg-hover); }
.tb-btn code { font: 12px var(--mono); }
.tb-a { text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 3px; }

/* ---------- popups & menus ---------- */

.popup {
  position: fixed; z-index: 70; background: var(--bg-elev); border-radius: 7px; box-shadow: var(--shadow);
  max-height: min(420px, 70vh); overflow-y: auto; outline: none;
}
.menu { min-width: 220px; max-width: 300px; padding: 5px; font-size: 14px; }
.menu-item { display: flex; align-items: center; gap: 8px; width: 100%; height: 30px; padding: 0 8px; border-radius: 4px; text-align: left; }
.menu-item.active, .menu-item:hover { background: var(--bg-hover); }
.menu-item.danger { color: var(--danger); }
.menu-item .ico { width: 17px; height: 17px; color: var(--text-2); }
.menu-item.danger .ico { color: var(--danger); }
.menu-label { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu-hint { font-size: 12px; color: var(--text-3); }
.menu-check { color: var(--accent); font-weight: 600; }
.menu-sub { width: 14px; height: 14px; color: var(--text-3); }
.menu-emoji { width: 18px; text-align: center; font-size: 13px; color: var(--text-2); }
.menu-sep { height: 1px; background: var(--border); margin: 5px -5px; }
.menu-header { font-size: 12px; font-weight: 600; color: var(--text-3); padding: 6px 8px 4px; }
.menu-foot { font-size: 12px; color: var(--text-3); padding: 4px 8px; line-height: 1.6; }
.color-row { display: flex; flex-wrap: wrap; gap: 5px; padding: 4px 8px 6px; }
.swatch { width: 20px; height: 20px; border-radius: 50%; border: 2px solid transparent; }
.swatch.on { border-color: var(--text); }
.swatch.none { background: var(--bg); box-shadow: inset 0 0 0 1px var(--border-strong); }
.sw-gray { background: var(--c-gray); } .sw-brown { background: var(--c-brown); } .sw-orange { background: var(--c-orange); }
.sw-yellow { background: var(--c-yellow); } .sw-green { background: var(--c-green); } .sw-blue { background: var(--c-blue); }
.sw-purple { background: var(--c-purple); } .sw-pink { background: var(--c-pink); } .sw-red { background: var(--c-red); }
.color-sample { width: 20px; height: 20px; display: grid; place-items: center; border-radius: 4px; box-shadow: inset 0 0 0 1px var(--border); font-weight: 600; font-size: 13px; }

.slash { width: 300px; padding: 5px; }
.slash-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 4px 6px; border-radius: 4px; text-align: left; }
.slash-item.active { background: var(--bg-hover); }
.slash-ic { width: 40px; height: 40px; flex: none; display: grid; place-items: center; border: 1px solid var(--border); border-radius: 5px; background: var(--bg); font-weight: 600; font-size: 15px; }
.slash-txt { display: flex; flex-direction: column; min-width: 0; }
.slash-label { font-size: 14px; }
.slash-desc { font-size: 12px; color: var(--text-3); }
.slash-empty { padding: 8px; color: var(--text-3); font-size: 14px; }

.emoji-picker { width: 352px; padding: 8px; }
.emoji-bar { display: flex; gap: 6px; margin-bottom: 8px; }
.emoji-grid { display: grid; grid-template-columns: repeat(10, 1fr); gap: 1px; }
.emoji { font-size: 22px; height: 32px; border-radius: 4px; line-height: 1; }
.emoji:hover { background: var(--bg-hover); }
.grad-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; padding: 4px 8px 6px; }
.grad { height: 34px; border-radius: 4px; background-size: cover; }
.grad:hover { outline: 2px solid var(--accent); }

/* ---------- modales ---------- */

.modal-back { position: fixed; inset: 0; z-index: 50; background: rgba(15, 15, 15, .45); display: flex; align-items: flex-start; justify-content: center; padding: 12vh 16px 16px; }
.modal { background: var(--bg-elev); border-radius: 10px; box-shadow: var(--shadow); width: min(560px, 100%); max-height: 76vh; display: flex; flex-direction: column; overflow: hidden; }
.modal.small { width: min(420px, 100%); }
.modal.medium { width: min(620px, 100%); }
.modal .ask, .modal .trash, .modal .settings { padding: 20px; display: flex; flex-direction: column; gap: 12px; min-height: 0; }
.modal-title { font-size: 17px; font-weight: 600; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }
.ask p { margin: 0; font-size: 14px; }

.search-modal { width: min(640px, 100%); }
.search { display: flex; flex-direction: column; min-height: 0; }
.search-bar { display: flex; align-items: center; gap: 10px; padding: 0 16px; border-bottom: 1px solid var(--border); color: var(--text-3); }
.search-input { color: var(--text); flex: 1; height: 52px; border: 0; outline: none; background: none; font-size: 17px; }
.search-list { overflow-y: auto; padding: 6px; max-height: 50vh; }
.search-item { display: flex; align-items: flex-start; gap: 10px; width: 100%; text-align: left; padding: 7px 10px; border-radius: 5px; }
.search-item.active, .search-item:hover { background: var(--bg-hover); }
.search-item .pg-icon { margin-top: 1px; }
.search-txt { min-width: 0; flex: 1; }
.search-title { font-size: 14px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.search-path { color: var(--text-3); font-weight: 400; }
.search-snip { font-size: 13px; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.search-snip mark { background: var(--b-yellow); color: inherit; border-radius: 2px; }
.search-empty { padding: 14px; font-size: 14px; }
.search-foot { font-size: 12px; padding: 8px 16px; border-top: 1px solid var(--border); }

.trash-list { overflow-y: auto; max-height: 48vh; display: flex; flex-direction: column; gap: 2px; }
.trash-item { display: flex; align-items: center; gap: 8px; padding: 5px 6px; border-radius: 5px; font-size: 14px; }
.trash-item:hover { background: var(--bg-hover); }
.trash-title { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.trash-empty { padding: 20px; text-align: center; }

.set-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 10px 0; border-top: 1px solid var(--border); }
.set-row.col { flex-direction: column; align-items: stretch; }
.set-label { font-weight: 500; font-size: 14px; }
.shortcuts { line-height: 1.8; text-align: right; }
.segmented { display: inline-flex; background: var(--bg-hover); border-radius: 6px; padding: 2px; }
.segmented button { padding: 4px 12px; border-radius: 4px; font-size: 13px; }
.segmented button.on { background: var(--bg-elev); box-shadow: 0 1px 2px rgba(0, 0, 0, .15); }

.toasts { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 90; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast { background: #2f2f2f; color: #fff; padding: 8px 14px; border-radius: 6px; font-size: 14px; box-shadow: var(--shadow); transition: opacity .3s, transform .3s; }
.toast.error { background: var(--danger); }
.toast.out { opacity: 0; transform: translateY(8px); }

/* ---------- bases de données ---------- */

.db { margin-top: 8px; }
.db-bar { display: flex; align-items: center; gap: 4px; padding-bottom: 6px; border-bottom: 1px solid var(--border); margin-bottom: 4px; }
.db-tab { display: flex; align-items: center; gap: 5px; padding: 4px 8px; border-radius: 5px; font-size: 14px; color: var(--text-2); }
.db-tab .ico { width: 16px; height: 16px; }
.db-tab:hover { background: var(--bg-hover); }
.db-tab.active { color: var(--text); font-weight: 500; box-shadow: inset 0 -2px 0 var(--text); border-radius: 5px 5px 0 0; }
.db-filter { width: 160px; }
.chip { font-size: 13px; padding: 3px 8px; border-radius: 12px; background: var(--accent-bg); color: var(--accent); white-space: nowrap; }
.db-table-wrap { overflow-x: auto; margin: 0 -4px; padding: 0 4px; }
.db-table { border-collapse: collapse; min-width: 100%; font-size: 14px; }
.th { text-align: left; font-weight: 400; color: var(--text-2); border-bottom: 1px solid var(--border); border-right: 1px solid var(--border); padding: 0; white-space: nowrap; min-width: 150px; }
.th:last-child, .td:last-child { border-right: 0; }
.th.add { min-width: 40px; width: 40px; }
.th-btn { display: flex; align-items: center; gap: 6px; width: 100%; height: 34px; padding: 0 8px; }
.th-btn:hover { background: var(--bg-hover); }
.th-btn .ico, .th.add svg { width: 16px; height: 16px; }
.th-ic { font-size: 12px; color: var(--text-3); width: 16px; text-align: center; flex: none; }
.th-name { overflow: hidden; text-overflow: ellipsis; }
.th-sort { color: var(--accent); }
.td { border-bottom: 1px solid var(--border); border-right: 1px solid var(--border); padding: 0; vertical-align: top; height: 36px; }
tr:hover .td { background: color-mix(in srgb, var(--bg-hover) 50%, transparent); }
.cell-title { display: flex; align-items: center; gap: 4px; padding: 0 6px 0 8px; min-height: 35px; position: relative; }
.cell-title-text { flex: 1; outline: none; font-weight: 500; padding: 7px 0; min-width: 60px; }
.cell-title-text:empty::before { content: attr(data-ph); color: var(--text-3); font-weight: 400; }
.open-btn { display: none; align-items: center; gap: 3px; font-size: 12px; color: var(--text-2); padding: 2px 6px; border-radius: 4px; border: 1px solid var(--border-strong); background: var(--bg-elev); flex: none; }
.open-btn .ico { width: 13px; height: 13px; }
tr:hover .open-btn { display: inline-flex; }
.row-icon { flex: none; }
.td-actions { width: 40px; border-right: 0; text-align: center; vertical-align: middle; }
.td-actions .icon-btn { opacity: 0; }
tr:hover .td-actions .icon-btn { opacity: 1; }
.cell-input { width: 100%; min-height: 35px; border: 0; background: none; outline: none; padding: 7px 8px; font-size: 14px; }
.cell-input:focus { background: var(--bg-elev); box-shadow: inset 0 0 0 2px var(--accent-bg); }
.cell-input.text { white-space: pre-wrap; word-break: break-word; }
.cell-input.text:empty::before, .cell-input::placeholder { content: attr(data-ph); color: transparent; }
.prop-val .cell-input.text:empty::before, .prop-val .cell-input::placeholder { color: var(--text-3); }
.prop-val input[type=date] { width: auto; }
.cell-input.num { text-align: right; font-variant-numeric: tabular-nums; }
.td-checkbox, .prop-val.td-checkbox { vertical-align: middle; }
.td-checkbox .cb { margin: 0 10px; }
.cb { width: 16px; height: 16px; accent-color: var(--accent); cursor: pointer; }
.url-cell { display: flex; align-items: center; }
.url-open { width: 22px; height: 22px; padding: 3px; margin-right: 4px; color: var(--text-2); border-radius: 4px; flex: none; }
.url-open:hover { background: var(--bg-hover); }
.select-cell { width: 100%; min-height: 35px; text-align: left; padding: 6px 8px; }
.select-cell .muted { color: transparent; }
.prop-val .select-cell .muted { color: var(--text-3); }
.pill { display: inline-block; padding: 0 7px; border-radius: 4px; font-size: 13px; line-height: 21px; white-space: nowrap; max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
.p-gray { background: var(--b-gray); color: var(--c-gray); } .p-brown { background: var(--b-brown); color: var(--c-brown); }
.p-orange { background: var(--b-orange); color: var(--c-orange); } .p-yellow { background: var(--b-yellow); color: var(--c-yellow); }
.p-green { background: var(--b-green); color: var(--c-green); } .p-blue { background: var(--b-blue); color: var(--c-blue); }
.p-purple { background: var(--b-purple); color: var(--c-purple); } .p-pink { background: var(--b-pink); color: var(--c-pink); }
.p-red { background: var(--b-red); color: var(--c-red); } .p-none { background: var(--bg-hover); color: var(--text-2); }
.db-add-row { display: flex; align-items: center; gap: 6px; width: 100%; height: 34px; padding: 0 8px; color: var(--text-3); font-size: 14px; border-bottom: 1px solid var(--border); }
.db-add-row:hover { background: var(--bg-hover); color: var(--text-2); }
.db-add-row .ico { width: 16px; height: 16px; }
.db-count { font-size: 12px; padding: 8px; }

.select-pop { width: 280px; padding: 8px; }
.sel-list { margin-top: 6px; display: flex; flex-direction: column; gap: 1px; }
.sel-item { display: flex; align-items: center; gap: 2px; padding: 3px 4px; border-radius: 4px; width: 100%; text-align: left; font-size: 14px; }
.sel-item:hover { background: var(--bg-hover); }
.sel-item.on { background: var(--accent-bg); }
.sel-item.create { gap: 6px; color: var(--text-2); }
.sel-pick { flex: 1; text-align: left; min-width: 0; display: flex; }
.sel-item .icon-btn { opacity: 0; }
.sel-item:hover .icon-btn { opacity: 1; }

.board { display: flex; gap: 14px; overflow-x: auto; padding: 8px 2px 16px; align-items: flex-start; }
.board-col { width: 260px; flex: none; }
.board-head { display: flex; align-items: center; gap: 8px; padding: 4px 2px 8px; }
.board-list { display: flex; flex-direction: column; gap: 8px; min-height: 40px; border-radius: 6px; padding: 2px; transition: background .12s; }
.board-list.over { background: var(--accent-bg); }
.card { background: var(--bg-elev); border-radius: 6px; padding: 10px; cursor: pointer; box-shadow: 0 0 0 1px var(--border), 0 1px 2px rgba(15, 15, 15, .08); font-size: 14px; }
:root[data-theme="dark"] .card { background: #2a2a2a; }
.card:hover { background: color-mix(in srgb, var(--bg-elev) 92%, var(--text)); }
.card.dragging { opacity: .4; }
.card-title { font-weight: 500; word-break: break-word; }
.card-metas { display: flex; flex-wrap: wrap; gap: 4px 6px; margin-top: 6px; align-items: center; }
.card-meta { font-size: 12px; color: var(--text-2); }
.board-add { display: flex; align-items: center; gap: 6px; width: 100%; padding: 6px 8px; color: var(--text-3); font-size: 14px; border-radius: 5px; margin-top: 6px; }
.board-add:hover { background: var(--bg-hover); }
.board-add .ico { width: 16px; height: 16px; }
.board-empty { padding: 30px; text-align: center; color: var(--text-2); }

.props-panel { margin: 4px 0 8px; font-size: 14px; }
.prop-row { display: flex; align-items: flex-start; min-height: 34px; }
.prop-name { width: 180px; flex: none; display: flex; align-items: center; gap: 6px; color: var(--text-2); padding: 7px 6px; }
.prop-val { flex: 1; min-width: 0; border-radius: 4px; display: flex; align-items: center; min-height: 34px; }
.prop-val:hover { background: var(--bg-hover); }
.prop-val .cb { margin: 0 8px; }
.props-panel > .ghost-btn { margin: 2px 0 0 0; }
.props-sep { border-top: 1px solid var(--border); margin: 12px 0 4px; }

/* ---------- responsive ---------- */

@media (max-width: 760px) {
  .sidebar { position: fixed; z-index: 40; top: 0; bottom: 0; left: 0; width: min(300px, 85vw); margin-left: -100%; box-shadow: var(--shadow); }
  .shell.sidebar-open .sidebar { margin-left: 0; }
  .shell.sidebar-open .sidebar-backdrop { display: block; position: fixed; inset: 0; z-index: 35; background: rgba(0, 0, 0, .35); }
  .resizer { display: none; }
  .show-sidebar { display: inline-flex; }
  .page { padding: 0 20px 30vh 34px; }
  .page-head { padding-top: 32px; }
  .page-title { font-size: 30px; }
  .blk-gutter { left: calc(var(--indent, 0) * 26px - 32px); }
  .blk-plus { display: none; }
  .blk:hover > .blk-gutter, .blk:focus-within > .blk-gutter { opacity: .8; }
  .status { display: none; }
  .prop-name { width: 120px; }
  .db-filter { width: 110px; }
  .crumb-title { max-width: 120px; }
  .cover-actions { opacity: 1; }
  .page-controls { opacity: 1; }
}

@media print {
  .sidebar, .topbar, .resizer, .blk-gutter, .editor-tail, .page-controls, .cover-actions, .code-bar { display: none !important; }
  .shell, .scroller { height: auto; overflow: visible; display: block; }
  .page { padding: 0; max-width: none; }
}

:root[data-theme="dark"] .sb-brand img, :root[data-theme="dark"] .auth-logo { filter: invert(1) brightness(.85); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .sb-brand img, :root:not([data-theme="light"]) .auth-logo { filter: invert(1) brightness(.85); }
}

.img-error { display: flex; flex-direction: column; gap: 4px; width: 100%; padding: 14px; border-radius: 6px; background: var(--b-red); color: var(--c-red); }
.img-error a { word-break: break-all; }

/* ---------- coloration syntaxique (highlight.js) ---------- */
:root {
  --hl-comment: #6a737d; --hl-keyword: #d73a49; --hl-string: #032f62; --hl-number: #005cc5; --hl-title: #6f42c1;
  --hl-attr: #005cc5; --hl-builtin: #e36209; --hl-tag: #22863a; --hl-meta: #735c0f; --hl-del: #b31d28; --hl-add: #22863a;
}
:root[data-theme="dark"] {
  --hl-comment: #8b949e; --hl-keyword: #ff7b72; --hl-string: #a5d6ff; --hl-number: #79c0ff; --hl-title: #d2a8ff;
  --hl-attr: #79c0ff; --hl-builtin: #ffa657; --hl-tag: #7ee787; --hl-meta: #d29922; --hl-del: #ffa198; --hl-add: #7ee787;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --hl-comment: #8b949e; --hl-keyword: #ff7b72; --hl-string: #a5d6ff; --hl-number: #79c0ff; --hl-title: #d2a8ff;
    --hl-attr: #79c0ff; --hl-builtin: #ffa657; --hl-tag: #7ee787; --hl-meta: #d29922; --hl-del: #ffa198; --hl-add: #7ee787;
  }
}
.hljs-comment, .hljs-quote { color: var(--hl-comment); font-style: italic; }
.hljs-keyword, .hljs-selector-tag, .hljs-type, .hljs-doctag, .hljs-template-tag { color: var(--hl-keyword); }
.hljs-string, .hljs-regexp, .hljs-template-variable, .hljs-char.escape_ { color: var(--hl-string); }
.hljs-number, .hljs-literal, .hljs-symbol, .hljs-bullet, .hljs-variable, .hljs-operator { color: var(--hl-number); }
.hljs-title, .hljs-title.function_, .hljs-title.class_, .hljs-section { color: var(--hl-title); }
.hljs-attr, .hljs-attribute, .hljs-property, .hljs-params, .hljs-selector-id, .hljs-selector-class { color: var(--hl-attr); }
.hljs-built_in, .hljs-subst { color: var(--hl-builtin); }
.hljs-name, .hljs-tag, .hljs-selector-attr, .hljs-selector-pseudo { color: var(--hl-tag); }
.hljs-meta, .hljs-meta .hljs-keyword { color: var(--hl-meta); }
.hljs-deletion { color: var(--hl-del); background: color-mix(in srgb, var(--hl-del) 12%, transparent); }
.hljs-addition { color: var(--hl-add); background: color-mix(in srgb, var(--hl-add) 12%, transparent); }
.hljs-emphasis { font-style: italic; } .hljs-strong { font-weight: 600; }

.auth-link { color: var(--text-2); font-size: 13px; text-decoration: underline; text-underline-offset: 2px; align-self: center; }
.auth-link:hover { color: var(--text); }
.auth-help { text-align: left; font-size: 13px; color: var(--text-2); background: var(--bg-hover); border-radius: 8px; padding: 12px 14px; }
.auth-help p { margin: 0 0 6px; font-size: 13px; }
.auth-help ol { margin: 0 0 6px; padding-left: 18px; }
.auth-help li { margin: 3px 0; }
.auth-help code { font-family: var(--mono); font-size: 12px; background: var(--bg-code); padding: 1px 4px; border-radius: 3px; }
.auth-warn { text-align: left; font-size: 13px; color: var(--c-orange); background: var(--b-orange); border-radius: 8px; padding: 10px 12px; }

/* Autocomplétion :emoji: */
.emoji-ac { width: 260px; padding: 5px; }
.emoji-ac-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 4px 8px; border-radius: 4px; text-align: left; }
.emoji-ac-item.active { background: var(--bg-hover); }
.emoji-ac-em { font-size: 20px; width: 26px; text-align: center; line-height: 1.2; }
.emoji-ac-code { font-size: 13px; color: var(--text-2); font-family: var(--mono); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.emoji-none { grid-column: 1 / -1; padding: 10px 4px; }
.emoji-picker .emoji-bar .input { flex: 1; }
