/* KKRI Brain : thème lumineux (esprit Monday, structure Notion) */
:root {
  --bg: #ffffff; --bg-soft: #f6f7fb; --bg-hover: #eceff8; --bg-active: #e4e7f5;
  --line: #e6e9ef; --line-strong: #d0d4e4;
  --text: #323338; --muted: #676879; --faint: #9699a6;
  --accent: #6161ff; --accent-dark: #4c4cdf; --accent-soft: #ebebff;
  --danger: #df2f4a; --ok: #00c875;
  --radius: 8px;
  --shadow-pop: 0 10px 32px rgba(50, 51, 56, .16), 0 1px 3px rgba(50, 51, 56, .1);
  --shadow-card: 0 1px 3px rgba(50, 51, 56, .1), 0 0 0 1px rgba(50, 51, 56, .04);
  --font: 'Figtree', 'Segoe UI', system-ui, -apple-system, sans-serif;
  --mono: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  --sbw: 264px;
}
* { box-sizing: border-box; margin: 0; }
html, body { height: 100%; }
body { background: var(--bg); color: var(--text); font: 15px/1.5 var(--font); -webkit-font-smoothing: antialiased; overflow: hidden; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; }
a { color: var(--accent); }
.ic { flex: none; vertical-align: middle; }
::selection { background: #cfd0ff; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #d3d6e3; border-radius: 10px; border: 2px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: #b9bdd0; background-clip: content-box; border: 2px solid transparent; }

/* ---------- Boutons et champs ---------- */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 6px; border: 1px solid var(--line-strong); background: #fff; font-weight: 500; font-size: 14px; }
.btn:hover { background: var(--bg-hover); }
.btn.sm { padding: 3px 9px; font-size: 13px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-dark); }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.ghost { border-color: transparent; color: var(--muted); }
.btn.ghost:hover { background: var(--bg-hover); color: var(--text); }
.input { width: 100%; padding: 8px 10px; border: 1px solid var(--line-strong); border-radius: 6px; outline: none; background: #fff; }
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.icon-btn { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 6px; color: var(--muted); }
.icon-btn:hover { background: var(--bg-hover); color: var(--text); }

/* ---------- Mise en page ---------- */
#app { display: grid; grid-template-columns: var(--sbw) 1fr; height: 100vh; transition: grid-template-columns .18s; }
#app.sb-collapsed { grid-template-columns: 0 1fr; }
#sidebar { background: var(--bg-soft); border-right: 1px solid var(--line); display: flex; flex-direction: column; overflow: hidden; min-width: 0; }
#app.sb-collapsed #sidebar { visibility: hidden; }
#main { display: flex; flex-direction: column; min-width: 0; height: 100vh; position: relative; }
#view { flex: 1; overflow: auto; position: relative; }

/* ---------- Barre latérale ---------- */
.sb-head { display: flex; align-items: center; gap: 10px; padding: 14px 14px 8px; }
.sb-logo { width: 28px; height: 28px; border-radius: 8px; background: linear-gradient(135deg, #6161ff, #a25ddc); color: #fff; display: grid; place-items: center; font-weight: 800; font-size: 15px; }
.sb-name { font-weight: 700; font-size: 16px; flex: 1; }
.sb-quick { padding: 4px 8px; display: flex; flex-direction: column; gap: 1px; }
.sb-link { display: flex; align-items: center; gap: 10px; padding: 6px 10px; border-radius: 6px; color: var(--muted); font-weight: 500; width: 100%; text-align: left; }
.sb-link:hover { background: var(--bg-hover); color: var(--text); }
.sb-link kbd { margin-left: auto; font: 11px var(--font); color: var(--faint); background: #fff; border: 1px solid var(--line); border-radius: 4px; padding: 0 5px; }
.sb-scroll { flex: 1; overflow: auto; padding: 8px 8px 16px; }
.sb-sec { display: flex; align-items: center; justify-content: space-between; padding: 12px 10px 4px; color: var(--faint); font-size: 12px; font-weight: 600; letter-spacing: .02em; }
.sb-sec .icon-btn { width: 22px; height: 22px; opacity: 0; }
.sb-sec:hover .icon-btn { opacity: 1; }
.sb-item { display: flex; align-items: center; gap: 2px; height: 30px; padding-right: 4px; border-radius: 6px; cursor: pointer; position: relative; color: var(--text); }
.sb-item:hover { background: var(--bg-hover); }
.sb-item.on { background: var(--accent-soft); color: var(--accent-dark); font-weight: 600; }
.sb-item.drop-in { background: var(--accent-soft); outline: 2px solid var(--accent); outline-offset: -2px; }
.sb-item.drop-before::before, .sb-item.drop-after::after { content: ''; position: absolute; left: 6px; right: 6px; height: 2px; background: var(--accent); border-radius: 2px; }
.sb-item.drop-before::before { top: -1px; } .sb-item.drop-after::after { bottom: -1px; }
.sb-chev { width: 20px; height: 20px; display: grid; place-items: center; border-radius: 4px; color: var(--faint); flex: none; }
.sb-chev:hover { background: rgba(0, 0, 0, .06); }
.sb-chev .ic { transition: transform .12s; }
.sb-chev.open .ic { transform: rotate(90deg); }
.sb-chev.leaf { visibility: hidden; }
.sb-ico { width: 22px; display: grid; place-items: center; flex: none; }
.sb-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-left: 4px; }
.sb-acts { display: none; gap: 1px; }
.sb-item:hover .sb-acts { display: flex; }
.sb-acts .icon-btn { width: 22px; height: 22px; }
.sb-foot { padding: 8px; border-top: 1px solid var(--line); }
.sb-demo { margin: 6px 10px; padding: 8px 10px; border-radius: 8px; background: #fff7e0; color: #7a5b00; font-size: 12px; line-height: 1.4; }
.pg-ico.none { color: var(--faint); display: inline-grid; }

/* ---------- Barre du haut ---------- */
.topbar { height: 46px; display: flex; align-items: center; gap: 6px; padding: 0 14px; flex: none; background: rgba(255, 255, 255, .92); backdrop-filter: blur(6px); border-bottom: 1px solid transparent; z-index: 5; }
.topbar.scrolled { border-bottom-color: var(--line); }
.crumbs { display: flex; align-items: center; gap: 2px; min-width: 0; flex: 1; overflow: hidden; }
.crumb { display: inline-flex; align-items: center; gap: 6px; padding: 3px 7px; border-radius: 6px; color: var(--muted); white-space: nowrap; max-width: 220px; overflow: hidden; text-overflow: ellipsis; font-size: 14px; }
.crumb:hover { background: var(--bg-hover); color: var(--text); }
.crumb.cur { color: var(--text); font-weight: 600; }
.crumb-sep { color: var(--faint); }
.sync { font-size: 12px; color: var(--faint); padding: 0 8px; white-space: nowrap; }
.sync.error { color: var(--danger); }

/* ---------- Page ---------- */
.page { max-width: 940px; margin: 0 auto; padding: 0 clamp(18px, 6vw, 80px) 160px; }
.page.wide { max-width: none; padding: 0 clamp(18px, 4vw, 56px) 120px; }
.cover { height: 200px; position: relative; margin: 0 calc(-1 * clamp(18px, 6vw, 80px)); background-size: cover; background-position: center; }
.page.wide .cover { margin: 0 calc(-1 * clamp(18px, 4vw, 56px)); }
.cover-acts { position: absolute; right: 18px; bottom: 12px; display: none; gap: 6px; }
.cover:hover .cover-acts { display: flex; }
.cover-acts .btn { background: rgba(255, 255, 255, .92); font-size: 12px; padding: 3px 9px; }
.page-head { position: relative; padding-top: 28px; }
.page-head.has-cover { padding-top: 0; }
.page-icon { font-size: 68px; line-height: 1; width: 86px; height: 86px; display: grid; place-items: center; border-radius: 12px; cursor: pointer; margin-bottom: 4px; }
.page-head.has-cover .page-icon { margin-top: -43px; position: relative; }
.page-icon:hover { background: var(--bg-hover); }
.page-icon.none { font-size: 14px; color: var(--faint); width: auto; height: auto; display: none; }
.page-head-acts { display: flex; gap: 6px; margin: 6px 0 2px; opacity: 0; transition: opacity .12s; min-height: 30px; }
.page-head:hover .page-head-acts, .page-head-acts:focus-within { opacity: 1; }
.page-title { font-size: 40px; font-weight: 800; line-height: 1.15; outline: none; padding: 4px 0 10px; word-break: break-word; letter-spacing: -.01em; }
.page-title:empty::before { content: attr(data-ph); color: #c3c6d4; }
.sec-title { font-size: 13px; font-weight: 600; color: var(--muted); margin: 28px 0 8px; }
.backlink { display: flex; align-items: center; gap: 8px; padding: 4px 8px; border-radius: 6px; cursor: pointer; color: var(--text); }
.backlink:hover { background: var(--bg-hover); }

/* ---------- Propriétés d'une ligne (fiche) ---------- */
.props { display: flex; flex-direction: column; gap: 2px; margin: 4px 0 18px; padding-bottom: 14px; border-bottom: 1px solid var(--line); }
.prop-row { display: flex; align-items: flex-start; min-height: 34px; }
.prop-label { width: 170px; flex: none; display: flex; align-items: center; gap: 8px; color: var(--muted); padding: 7px 8px; border-radius: 6px; font-size: 14px; cursor: default; }
.prop-label.edit { cursor: pointer; }
.prop-label.edit:hover { background: var(--bg-hover); }
.prop-val { flex: 1; min-width: 0; }
.prop-val .cell { min-height: 34px; padding: 4px 8px; border-radius: 6px; cursor: pointer; display: flex; align-items: center; flex-wrap: wrap; gap: 4px; }
.prop-val .cell:hover { background: var(--bg-hover); }
.add-prop { color: var(--faint); font-size: 14px; display: inline-flex; align-items: center; gap: 6px; padding: 5px 8px; border-radius: 6px; margin-top: 4px; width: fit-content; }
.add-prop:hover { background: var(--bg-hover); color: var(--text); }

/* ---------- Éditeur de blocs ---------- */
.editor { padding-bottom: 80px; margin-left: 0; }
.blk { position: relative; padding: 1px 0; border-radius: 4px; }
.blk.drop-before::before, .blk.drop-after::after { content: ''; position: absolute; left: 0; right: 0; height: 3px; background: var(--accent); border-radius: 3px; z-index: 2; }
.blk.drop-before::before { top: -2px; } .blk.drop-after::after { bottom: -2px; }
.blk.dragging { opacity: .35; }
.blk-ctrl { position: absolute; left: -54px; top: 3px; display: flex; opacity: 0; transition: opacity .1s; }
.blk:hover > .blk-ctrl, .blk-ctrl:focus-within { opacity: 1; }
.blk-ctrl button { width: 24px; height: 26px; display: grid; place-items: center; border-radius: 5px; color: var(--faint); }
.blk-ctrl button:hover { background: var(--bg-hover); color: var(--text); }
.blk-ctrl .grip { cursor: grab; }
.blk-row { display: flex; align-items: flex-start; gap: 4px; }
.blk-mark { flex: none; width: 26px; min-height: 1.6em; display: flex; align-items: center; justify-content: center; color: var(--text); user-select: none; }
.blk-text { flex: 1; min-width: 0; outline: none; white-space: pre-wrap; word-break: break-word; line-height: 1.6; padding: 2px 2px; min-height: 1.6em; caret-color: var(--text); }
.blk-text:empty::before { content: attr(data-ph); color: #c3c6d4; pointer-events: none; }
.blk[data-type=p] .blk-text:empty::before { content: ''; }
.blk[data-type=p].focus .blk-text:empty::before { content: attr(data-ph); }
.blk[data-type=p] .blk-mark, .blk[data-type=h1] .blk-mark, .blk[data-type=h2] .blk-mark, .blk[data-type=h3] .blk-mark { display: none; }
.blk[data-type=h1] .blk-text { font-size: 30px; font-weight: 800; line-height: 1.25; margin-top: 18px; }
.blk[data-type=h2] .blk-text { font-size: 23px; font-weight: 700; line-height: 1.3; margin-top: 14px; }
.blk[data-type=h3] .blk-text { font-size: 18px; font-weight: 700; line-height: 1.35; margin-top: 10px; }
.blk[data-type=h1] .blk-ctrl { top: 22px; } .blk[data-type=h2] .blk-ctrl { top: 17px; } .blk[data-type=h3] .blk-ctrl { top: 12px; }
.bullet-dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.num-mark { font-variant-numeric: tabular-nums; color: var(--muted); font-weight: 500; }
.todo-box { width: 17px; height: 17px; border: 2px solid #b4b8c9; border-radius: 4px; display: grid; place-items: center; cursor: pointer; margin-top: 0; }
.todo-box:hover { border-color: var(--accent); }
.todo-box.on { background: var(--ok); border-color: var(--ok); color: #fff; }
.blk.done > .blk-row .blk-text { color: var(--faint); text-decoration: line-through; }
.tgl-btn { width: 22px; height: 22px; display: grid; place-items: center; border-radius: 4px; cursor: pointer; color: var(--muted); }
.tgl-btn:hover { background: var(--bg-hover); }
.tgl-btn .ic { transition: transform .12s; }
.tgl-btn.open .ic { transform: rotate(90deg); }
.blk[data-type=quote] .blk-row { border-left: 3px solid var(--accent); padding-left: 12px; margin-left: 4px; }
.blk[data-type=quote] .blk-mark { display: none; }
.blk[data-type=quote] .blk-text { font-size: 17px; }
.blk[data-type=callout] .blk-row { background: #f6f7fb; border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; align-items: flex-start; }
.blk[data-type=callout] .blk-mark { cursor: pointer; font-size: 21px; width: 32px; border-radius: 6px; }
.blk[data-type=callout] .blk-mark:hover { background: rgba(0, 0, 0, .05); }
.blk[data-type=code] .blk-row { background: #f6f7fb; border-radius: 10px; border: 1px solid var(--line); padding: 10px 14px 12px; display: block; position: relative; }
.blk[data-type=code] .blk-mark { display: none; }
.blk[data-type=code] .blk-text { font-family: var(--mono); font-size: 13.5px; line-height: 1.55; white-space: pre; overflow-x: auto; tab-size: 2; }
.code-lang { position: absolute; right: 10px; top: 6px; font-size: 12px; color: var(--faint); background: transparent; border: 0; cursor: pointer; border-radius: 4px; padding: 1px 6px; }
.code-lang:hover { background: var(--bg-hover); }
.blk hr { border: 0; border-top: 1px solid var(--line-strong); margin: 12px 0; }
.blk-img { margin: 6px 0; }
.blk-img img { max-width: 100%; border-radius: 8px; display: block; }
.img-empty { display: flex; align-items: center; gap: 10px; padding: 14px 16px; background: var(--bg-soft); border-radius: 8px; color: var(--muted); cursor: pointer; }
.img-empty:hover { background: var(--bg-hover); }
.blk-pagelink { display: flex; align-items: center; gap: 8px; padding: 5px 8px; border-radius: 6px; cursor: pointer; font-weight: 500; border-bottom: 1px solid transparent; }
.blk-pagelink:hover { background: var(--bg-hover); }
.blk-pagelink .t { text-decoration: underline; text-decoration-color: var(--line-strong); text-underline-offset: 3px; }
.blk-db { margin: 10px 0; }
.blk-text a { color: var(--accent); text-decoration: underline; text-underline-offset: 2px; }
.blk-text code { font-family: var(--mono); font-size: .88em; background: #eceff8; color: #c9324d; padding: 1px 5px; border-radius: 4px; }
.mention { display: inline-flex; align-items: center; gap: 3px; padding: 0 6px; margin: 0 1px; border-radius: 5px; background: var(--accent-soft); color: var(--accent-dark); font-weight: 500; cursor: pointer; user-select: all; }
.mention:hover { background: #dcdcff; }
.c-text-gray { color: #8a8d9f; } .c-text-brown { color: #7f5347; } .c-text-orange { color: #e67e00; } .c-text-yellow { color: #b38600; } .c-text-lime { color: #5f8a00; } .c-text-green { color: #00854d; }
.c-text-teal { color: #0f8f8a; } .c-text-blue { color: #1f6fe0; } .c-text-indigo { color: #4545e6; } .c-text-purple { color: #8036c4; } .c-text-pink { color: #d6239a; } .c-text-red { color: #c4162f; }
.c-bg-gray > .blk-row { background: #f0f1f5 !important; } .c-bg-brown > .blk-row { background: #f0e6e2 !important; } .c-bg-orange > .blk-row { background: #fff0db !important; }
.c-bg-yellow > .blk-row { background: #fff6cc !important; } .c-bg-lime > .blk-row { background: #eef8d4 !important; } .c-bg-green > .blk-row { background: #d9f6e8 !important; }
.c-bg-teal > .blk-row { background: #dbf5f3 !important; } .c-bg-blue > .blk-row { background: #e0ecff !important; } .c-bg-indigo > .blk-row { background: #e6e6ff !important; }
.c-bg-purple > .blk-row { background: #f0e4fa !important; } .c-bg-pink > .blk-row { background: #ffe4f6 !important; } .c-bg-red > .blk-row { background: #fde0e4 !important; }
[class*=c-bg-] > .blk-row { border-radius: 6px; padding-left: 6px; padding-right: 6px; }
.editor-empty { color: #c3c6d4; padding: 4px 2px; cursor: text; }

/* ---------- Popups, menus, modales ---------- */
.popup { position: fixed; z-index: 1000; background: #fff; border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow-pop); max-height: min(70vh, 560px); overflow: auto; animation: pop .1s ease-out; }
@keyframes pop { from { opacity: 0; transform: translateY(-3px); } }
.menu { padding: 6px; min-width: 210px; }
.menu-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 6px 10px; border-radius: 6px; text-align: left; font-size: 14px; }
.menu-item:hover:not(:disabled) { background: var(--bg-hover); }
.menu-item:disabled { color: var(--faint); cursor: default; }
.menu-item.danger { color: var(--danger); }
.menu-item .mi { color: var(--muted); display: grid; place-items: center; width: 18px; }
.menu-item.danger .mi { color: var(--danger); }
.menu-item .ml { flex: 1; }
.menu-item .mr { color: var(--faint); font-size: 12px; display: grid; }
.menu-sep { height: 1px; background: var(--line); margin: 5px 4px; }
.menu-h { padding: 6px 10px 3px; font-size: 12px; font-weight: 600; color: var(--faint); }
.dot { display: inline-block; width: 14px; height: 14px; border-radius: 4px; }
.overlay { position: fixed; inset: 0; background: rgba(50, 51, 56, .38); z-index: 900; display: flex; align-items: flex-start; justify-content: center; padding-top: 12vh; animation: fade .12s; }
@keyframes fade { from { opacity: 0; } }
.modal { background: #fff; border-radius: 14px; box-shadow: var(--shadow-pop); max-width: calc(100vw - 24px); max-height: 80vh; display: flex; flex-direction: column; overflow: hidden; }
.dlg { padding: 20px 22px 18px; display: flex; flex-direction: column; gap: 14px; }
.dlg h3 { font-size: 17px; }
.dlg-btns { display: flex; justify-content: flex-end; gap: 8px; }
.toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); background: #323338; color: #fff; padding: 10px 16px; border-radius: 10px; z-index: 2000; display: flex; gap: 14px; align-items: center; box-shadow: var(--shadow-pop); font-size: 14px; }
.toast button { color: #b9b9ff; font-weight: 600; }
.emoji-wrap { padding: 0; }
.emoji-top { display: flex; gap: 6px; padding: 8px; border-bottom: 1px solid var(--line); }
.emoji-scroll { max-height: 300px; overflow: auto; padding: 4px 8px 10px; }
.emoji-cat { font-size: 12px; font-weight: 600; color: var(--faint); margin: 8px 2px 4px; }
.emoji-grid { display: grid; grid-template-columns: repeat(9, 1fr); }
.emoji { font-size: 21px; padding: 3px; border-radius: 6px; line-height: 1.3; }
.emoji:hover { background: var(--bg-hover); }
.slash-menu { width: 300px; padding: 6px; }
.slash-item { display: flex; align-items: center; gap: 12px; width: 100%; padding: 6px 8px; border-radius: 8px; text-align: left; }
.slash-item.sel, .slash-item:hover { background: var(--bg-hover); }
.slash-ic { width: 38px; height: 38px; border: 1px solid var(--line); border-radius: 8px; display: grid; place-items: center; color: var(--muted); background: #fff; flex: none; }
.slash-t { font-weight: 600; font-size: 14px; }
.slash-d { font-size: 12px; color: var(--faint); }
.slash-h { font-size: 12px; font-weight: 600; color: var(--faint); padding: 6px 8px 2px; }
.slash-none { padding: 14px; color: var(--faint); text-align: center; font-size: 14px; }
.fmt-bar { position: fixed; z-index: 1001; background: #323338; border-radius: 8px; padding: 3px; display: flex; gap: 1px; box-shadow: var(--shadow-pop); }
.fmt-bar button { color: #fff; min-width: 30px; height: 28px; border-radius: 6px; font-weight: 700; font-size: 14px; display: grid; place-items: center; padding: 0 6px; }
.fmt-bar button:hover { background: rgba(255, 255, 255, .16); }
.fmt-bar button.on { background: var(--accent); }
.fmt-bar .sep { width: 1px; background: rgba(255, 255, 255, .22); margin: 4px 3px; }

/* ---------- Pastilles ---------- */
.pill { display: inline-flex; align-items: center; gap: 4px; padding: 1px 10px; border-radius: 999px; font-size: 13px; font-weight: 500; line-height: 21px; white-space: nowrap; max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
.pill .x { opacity: .7; cursor: pointer; margin-left: 2px; }
.rel-chip { display: inline-flex; align-items: center; gap: 5px; padding: 0 8px; border-radius: 6px; background: var(--bg-soft); border: 1px solid var(--line); font-size: 13px; line-height: 22px; cursor: pointer; max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rel-chip:hover { background: var(--accent-soft); border-color: #c9c9ff; }
.muted { color: var(--faint); }
.opt-search { padding: 8px; border-bottom: 1px solid var(--line); }
.opt-search input { width: 100%; border: 0; outline: none; padding: 4px 6px; }
.opt-list { padding: 6px; }
.opt-item { display: flex; align-items: center; gap: 8px; padding: 5px 8px; border-radius: 6px; cursor: pointer; width: 100%; text-align: left; }
.opt-item:hover, .opt-item.sel { background: var(--bg-hover); }
.opt-item .grow { flex: 1; min-width: 0; }
.opt-hint { padding: 6px 12px; color: var(--faint); font-size: 12px; }
.opt-edit { display: flex; align-items: center; gap: 6px; padding: 3px 4px; }
.opt-edit input { flex: 1; border: 1px solid transparent; padding: 4px 6px; border-radius: 6px; outline: none; min-width: 0; }
.opt-edit input:hover, .opt-edit input:focus { border-color: var(--line-strong); }
.opt-edit .dot { width: 20px; height: 20px; border-radius: 6px; cursor: pointer; }
.pop-pad { padding: 12px; display: flex; flex-direction: column; gap: 10px; }
.pop-pad label { font-size: 12px; color: var(--muted); font-weight: 600; display: block; margin-bottom: 4px; }
.pop-pad select.input { appearance: auto; }
.filter-row { display: flex; gap: 6px; align-items: center; padding: 3px 0; }
.filter-row select, .filter-row input { padding: 5px 7px; border: 1px solid var(--line-strong); border-radius: 6px; background: #fff; outline: none; min-width: 0; }
.filter-row input:focus, .filter-row select:focus { border-color: var(--accent); }

/* ---------- Base de données ---------- */
.db { position: relative; }
.db-bar { display: flex; align-items: center; gap: 4px; border-bottom: 1px solid var(--line); min-height: 40px; flex-wrap: wrap; }
.db-tabs { display: flex; align-items: center; gap: 2px; flex: 1; min-width: 0; overflow-x: auto; }
.db-tab { display: inline-flex; align-items: center; gap: 6px; padding: 8px 10px; color: var(--muted); font-weight: 500; font-size: 14px; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; border-radius: 6px 6px 0 0; }
.db-tab:hover { background: var(--bg-hover); color: var(--text); }
.db-tab.on { color: var(--accent-dark); border-bottom-color: var(--accent); font-weight: 600; }
.db-tools { display: flex; align-items: center; gap: 2px; }
.db-tool { display: inline-flex; align-items: center; gap: 6px; padding: 5px 9px; border-radius: 6px; color: var(--muted); font-size: 14px; font-weight: 500; }
.db-tool:hover { background: var(--bg-hover); color: var(--text); }
.db-tool.active { color: var(--accent-dark); background: var(--accent-soft); }
.db-search { display: flex; align-items: center; gap: 6px; border: 1px solid var(--line-strong); border-radius: 6px; padding: 0 8px; }
.db-search input { border: 0; outline: none; padding: 5px 0; width: 150px; }
.new-split { display: inline-flex; margin-left: 6px; }
.new-split .btn { border-radius: 6px 0 0 6px; }
.new-split .btn + .btn { border-radius: 0 6px 6px 0; border-left: 1px solid rgba(255, 255, 255, .35); padding: 6px 7px; }
.db-chips { display: flex; gap: 6px; flex-wrap: wrap; padding: 8px 0 2px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 2px 4px 2px 10px; background: var(--accent-soft); color: var(--accent-dark); border-radius: 999px; font-size: 13px; font-weight: 500; cursor: pointer; }
.chip .icon-btn { width: 20px; height: 20px; color: var(--accent-dark); }
.db-body { padding-top: 10px; }
.db-title-row { display: flex; align-items: center; gap: 8px; padding: 4px 0 6px; }
.db-title-row .t { font-weight: 700; font-size: 17px; cursor: pointer; }
.db-title-row .t:hover { text-decoration: underline; text-decoration-color: var(--line-strong); }
.db-empty { padding: 26px; text-align: center; color: var(--faint); }

/* Tableau */
.tbl-wrap { overflow-x: auto; padding-bottom: 6px; }
.tbl { min-width: max-content; }
.tr { display: flex; border-bottom: 1px solid var(--line); position: relative; }
.tr:hover { background: #fafbfe; }
.th { height: 34px; display: flex; align-items: center; gap: 7px; padding: 0 10px; color: var(--muted); font-size: 13px; font-weight: 500; cursor: pointer; position: relative; flex: none; border-right: 1px solid var(--line); white-space: nowrap; background: #fff; }
.th:hover { background: var(--bg-hover); }
.th.add { width: 44px; justify-content: center; border-right: 0; }
.th .rs { position: absolute; right: -3px; top: 0; bottom: 0; width: 7px; cursor: col-resize; z-index: 2; }
.th .rs:hover { background: var(--accent); opacity: .5; }
.tr.head { border-top: 1px solid var(--line); }
.td { min-height: 36px; display: flex; align-items: center; flex-wrap: wrap; gap: 4px; padding: 3px 10px; border-right: 1px solid var(--line); flex: none; font-size: 14px; position: relative; cursor: pointer; overflow: hidden; }
.td.sticky, .th.sticky { position: sticky; left: 0; z-index: 3; }
.td.sticky { background: #fff; }
.tr:hover .td.sticky { background: #fafbfe; }
.td.title { font-weight: 500; }
.td.title .t { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; outline: none; }
.td.title .t[contenteditable=true] { overflow: visible; white-space: normal; background: #fff; box-shadow: 0 0 0 2px var(--accent); border-radius: 4px; padding: 0 3px; }
.td .open-btn { display: none; align-items: center; gap: 4px; font-size: 12px; font-weight: 600; color: var(--muted); border: 1px solid var(--line-strong); background: #fff; border-radius: 6px; padding: 1px 7px; cursor: pointer; flex: none; }
.td:hover .open-btn { display: inline-flex; }
.td .open-btn:hover { background: var(--bg-hover); color: var(--text); }
.td.num { justify-content: flex-end; }
.td.status { padding: 0; }
.status-fill { width: 100%; height: 100%; min-height: 36px; display: flex; align-items: center; justify-content: center; font-weight: 500; font-size: 14px; padding: 0 8px; text-align: center; }
.td.empty-hint:hover::after { content: ''; }
.td .cell-input { width: 100%; border: 0; outline: none; background: transparent; padding: 4px 0; font: inherit; }
.td.editing { box-shadow: inset 0 0 0 2px var(--accent); background: #fff; }
.tr.add-row { color: var(--faint); cursor: pointer; }
.tr.add-row:hover { background: var(--bg-hover); color: var(--text); }
.tr.add-row .td { border-right: 0; cursor: pointer; }
.grp-h { display: flex; align-items: center; gap: 8px; padding: 14px 4px 6px; position: sticky; left: 0; }
.grp-h .chev { width: 22px; height: 22px; display: grid; place-items: center; border-radius: 5px; color: var(--muted); }
.grp-h .chev:hover { background: var(--bg-hover); }
.grp-h .gt { font-weight: 700; font-size: 15px; }
.grp-h .gc { color: var(--faint); font-size: 13px; }
.grp-bar { position: absolute; left: 0; top: 0; bottom: 0; width: 5px; z-index: 4; }
.tr .td.sticky:first-child, .tr .th.sticky:first-child { padding-left: 16px; }

/* Kanban */
.board { display: flex; gap: 14px; overflow-x: auto; align-items: flex-start; padding-bottom: 16px; min-height: 240px; }
.col { width: 290px; flex: none; background: var(--bg-soft); border-radius: 12px; padding: 10px; display: flex; flex-direction: column; gap: 8px; max-height: 100%; }
.col.over { outline: 2px dashed var(--accent); outline-offset: -2px; background: var(--accent-soft); }
.col-h { display: flex; align-items: center; gap: 8px; padding: 2px 4px 6px; }
.col-h .n { color: var(--faint); font-size: 13px; }
.col-h .grow { flex: 1; }
.card { background: #fff; border-radius: 10px; padding: 10px 12px; box-shadow: var(--shadow-card); cursor: pointer; display: flex; flex-direction: column; gap: 8px; border-left: 4px solid var(--cc, transparent); }
.card:hover { box-shadow: 0 2px 10px rgba(50, 51, 56, .16), 0 0 0 1px var(--line-strong); }
.card.dragging { opacity: .4; }
.card-t { font-weight: 600; display: flex; gap: 6px; align-items: flex-start; word-break: break-word; }
.card-p { display: flex; gap: 5px; flex-wrap: wrap; align-items: center; font-size: 13px; color: var(--muted); }
.col-add { color: var(--muted); padding: 6px 8px; border-radius: 8px; display: flex; gap: 6px; align-items: center; font-size: 14px; }
.col-add:hover { background: var(--bg-active); color: var(--text); }

/* Calendrier */
.cal-head { display: flex; align-items: center; gap: 8px; padding: 4px 0 10px; }
.cal-head .m { font-weight: 700; font-size: 17px; min-width: 150px; text-transform: capitalize; }
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.cal-dow { padding: 6px 8px; font-size: 12px; font-weight: 600; color: var(--faint); background: var(--bg-soft); border-bottom: 1px solid var(--line); text-transform: capitalize; }
.cal-day { min-height: 112px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: 4px; display: flex; flex-direction: column; gap: 3px; position: relative; min-width: 0; }
.cal-day:nth-child(7n) { border-right: 0; }
.cal-day.other { background: #fafbfd; color: var(--faint); }
.cal-day.over { background: var(--accent-soft); }
.cal-num { font-size: 13px; padding: 1px 6px; align-self: flex-start; border-radius: 999px; font-weight: 500; }
.cal-day.today .cal-num { background: var(--accent); color: #fff; font-weight: 700; }
.cal-add { position: absolute; top: 3px; right: 4px; opacity: 0; width: 22px; height: 22px; }
.cal-day:hover .cal-add { opacity: 1; }
.cal-chip { font-size: 12.5px; padding: 2px 7px; border-radius: 5px; color: #fff; cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 500; }
.cal-chip:hover { filter: brightness(.94); }

/* Galerie et liste */
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; }
.gal-card { background: #fff; border-radius: 12px; overflow: hidden; box-shadow: var(--shadow-card); cursor: pointer; display: flex; flex-direction: column; }
.gal-card:hover { box-shadow: 0 4px 16px rgba(50, 51, 56, .16), 0 0 0 1px var(--line-strong); }
.gal-cover { height: 110px; background: var(--bg-soft); display: grid; place-items: center; font-size: 38px; }
.gal-body { padding: 12px 14px 14px; display: flex; flex-direction: column; gap: 8px; }
.gal-add { border: 2px dashed var(--line-strong); border-radius: 12px; min-height: 170px; display: grid; place-items: center; color: var(--faint); cursor: pointer; }
.gal-add:hover { background: var(--bg-soft); color: var(--text); }
.lst-row { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-bottom: 1px solid var(--line); cursor: pointer; }
.lst-row:hover { background: var(--bg-soft); }
.lst-row .t { font-weight: 500; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lst-props { display: flex; gap: 8px; align-items: center; }

/* ---------- Fiche (peek) ---------- */
.peek-back { position: fixed; inset: 0; background: rgba(50, 51, 56, .22); z-index: 700; animation: fade .12s; }
.peek { position: fixed; top: 0; right: 0; bottom: 0; width: min(760px, 100vw); background: #fff; z-index: 710; box-shadow: -12px 0 40px rgba(50, 51, 56, .18); display: flex; flex-direction: column; animation: slide .16s ease-out; }
@keyframes slide { from { transform: translateX(40px); opacity: 0; } }
.peek-bar { display: flex; align-items: center; gap: 6px; padding: 10px 14px; border-bottom: 1px solid var(--line); }
.peek-bar .grow { flex: 1; }
.peek-body { flex: 1; overflow: auto; }
.peek .page { padding-bottom: 100px; }

/* ---------- Recherche ---------- */
.search-modal .s-in { display: flex; align-items: center; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--line); color: var(--muted); }
.search-modal input { flex: 1; border: 0; outline: none; font-size: 17px; }
.search-modal .s-list { overflow: auto; padding: 8px; max-height: 52vh; }
.s-item { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; cursor: pointer; width: 100%; text-align: left; }
.s-item.sel, .s-item:hover { background: var(--bg-hover); }
.s-item .grow { flex: 1; min-width: 0; }
.s-item .t { font-weight: 500; }
.s-item .sn { font-size: 12.5px; color: var(--faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.s-h { font-size: 12px; font-weight: 600; color: var(--faint); padding: 8px 10px 4px; }

/* ---------- Accueil / corbeille ---------- */
.home h1 { font-size: 34px; font-weight: 800; padding-top: 48px; letter-spacing: -.01em; }
.home .sub { color: var(--muted); margin: 4px 0 26px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 12px; }
.tile { border: 1px solid var(--line); border-radius: 12px; padding: 14px; cursor: pointer; display: flex; flex-direction: column; gap: 10px; background: #fff; text-align: left; }
.tile:hover { box-shadow: var(--shadow-card); border-color: var(--line-strong); }
.tile .tt { font-weight: 600; }
.tile .ts { font-size: 12px; color: var(--faint); }
.trash-row { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-bottom: 1px solid var(--line); }
.trash-row .grow { flex: 1; }

/* ---------- Mobile ---------- */
@media (max-width: 820px) {
  #app, #app.sb-collapsed { grid-template-columns: 1fr; }
  #sidebar { position: fixed; z-index: 800; top: 0; bottom: 0; left: 0; width: min(300px, 86vw); transform: translateX(-102%); transition: transform .18s; box-shadow: var(--shadow-pop); visibility: visible !important; }
  #app.sb-open #sidebar { transform: none; }
  .sb-scrim { position: fixed; inset: 0; background: rgba(50, 51, 56, .3); z-index: 790; display: none; }
  #app.sb-open .sb-scrim { display: block; }
  .page-title { font-size: 30px; }
  .blk-ctrl { left: -2px; top: -2px; background: #fff; border-radius: 6px; box-shadow: var(--shadow-card); z-index: 3; }
  .blk-ctrl .plus { display: none; }
  .prop-label { width: 120px; }
  .page { padding-left: 18px; padding-right: 18px; }
  .td .open-btn { display: inline-flex; }
}
@media (min-width: 821px) { .sb-scrim { display: none !important; } #mob-menu { display: none; } }

/* ---------- Ajustements tableau ---------- */
.tbl .td .cell, .tbl .td > * { flex-wrap: nowrap; }
.tbl .td { overflow: hidden; white-space: nowrap; }
.tbl .td .cell { overflow: hidden; }
