:root {
  --bg: #faf9f7; --panel: #ffffff; --side: #f3f1ed; --line: #e4e0d8; --text: #1f2328; --muted: #6b6f76;
  --accent: #c8643c; --accent-soft: #fbeee7; --code: #f4f2ee; --user: #eef3fb; --shadow: 0 1px 2px rgba(0,0,0,.05);
  --top: 52px; --sidew: 300px;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}
:root[data-theme="dark"] {
  --bg: #16181d; --panel: #1d2026; --side: #1a1c21; --line: #2e323a; --text: #e6e6e3; --muted: #9499a3;
  --accent: #e8875f; --accent-soft: #3a2a22; --code: #23262d; --user: #212a38; --shadow: none;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.55 var(--sans); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
[hidden] { display: none !important; }
.muted { color: var(--muted); } .small { font-size: 12.5px; } .nowrap { white-space: nowrap; } .mono { font-family: var(--mono); font-size: 12px; }
.pad { padding: 14px; }

/* barre du haut */
#top { position: sticky; top: 0; z-index: 30; height: var(--top); display: flex; align-items: center; gap: 12px;
  padding: 0 max(14px, env(safe-area-inset-right)) 0 max(14px, env(safe-area-inset-left)); background: var(--panel); border-bottom: 1px solid var(--line); }
.brand { font-weight: 700; color: var(--text); font-size: 16px; white-space: nowrap; }
.brand:hover { text-decoration: none; }
.logo { color: var(--accent); }
#nav { display: flex; gap: 2px; }
#nav a { color: var(--muted); padding: 6px 10px; border-radius: 7px; font-weight: 500; }
#nav a:hover { background: var(--side); text-decoration: none; }
#nav a.on { color: var(--text); background: var(--side); }
#search { flex: 1; display: flex; justify-content: flex-end; min-width: 0; }
#q { width: 100%; max-width: 360px; }
input[type=search] { font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; outline: none; -webkit-appearance: none; }
input[type=search]:focus { border-color: var(--accent); }
.icon { font: inherit; font-size: 18px; background: none; border: 0; color: var(--text); cursor: pointer; padding: 6px 8px; border-radius: 7px; }
.icon:hover { background: var(--side); }

/* structure */
#layout { display: flex; align-items: flex-start; }
#side { position: sticky; top: var(--top); width: var(--sidew); flex: none; height: calc(100dvh - var(--top)); overflow: hidden;
  display: flex; flex-direction: column; background: var(--side); border-right: 1px solid var(--line); }
#main { flex: 1; min-width: 0; }
.page { max-width: 1120px; margin: 0 auto; padding: 22px 26px 80px; }
.page.wide { max-width: none; padding-bottom: 16px; }
#scrim { display: none; }

.side-title { display: block; padding: 12px 14px 8px; font-weight: 700; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tabs { display: flex; gap: 2px; padding: 0 10px 8px; border-bottom: 1px solid var(--line); }
.tab { flex: 1; font: inherit; font-size: 13px; padding: 5px 4px; border: 0; background: none; color: var(--muted); border-radius: 6px; cursor: pointer; }
.tab.on { background: var(--panel); color: var(--text); font-weight: 600; box-shadow: var(--shadow); }
.side-body { flex: 1; overflow: auto; padding: 10px 8px 30px; -webkit-overflow-scrolling: touch; }
.filter { width: 100%; font-size: 13px; }
.check { display: block; font-size: 12.5px; color: var(--muted); margin: 8px 4px; cursor: pointer; }

/* arbre */
.tree { font-size: 13.5px; }
.tree details > summary { list-style: none; display: flex; align-items: center; padding: 3px 6px; border-radius: 6px; cursor: pointer; }
.tree summary::-webkit-details-marker { display: none; }
.tree summary .tw::before { content: "▸"; display: inline-block; width: 14px; color: var(--muted); font-size: 11px; }
.tree details[open] > summary .tw::before { content: "▾"; }
.tree summary a { color: var(--text); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tree .kids { margin-left: 11px; padding-left: 6px; border-left: 1px solid var(--line); }
.leaf { display: block; padding: 3px 6px 3px 8px; border-radius: 6px; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.leaf .ic { font-size: 11px; margin-right: 6px; opacity: .85; }
.leaf:hover, .tree summary:hover, .sitem:hover { background: color-mix(in srgb, var(--text) 7%, transparent); text-decoration: none; }
.cur, .leaf.cur { background: var(--accent-soft) !important; }
.leaf.cur, summary.cur a { color: var(--accent); }
.slist { display: flex; flex-direction: column; gap: 2px; }
.sitem { display: block; padding: 7px 8px; border-radius: 7px; color: var(--text); }
.sitem-t { font-size: 13.5px; font-weight: 500; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

/* accueil, cartes, listes */
.hero { font-size: 30px; margin: 8px 0 2px; letter-spacing: -.02em; }
.lead { margin: 0 0 8px; }
.sec { font-size: 12.5px; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); margin: 30px 0 10px; font-weight: 600; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 12px; }
.card { display: flex; flex-direction: column; gap: 5px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 14px 15px; color: var(--text); box-shadow: var(--shadow); transition: border-color .12s, transform .12s; }
.card:hover { border-color: var(--accent); text-decoration: none; transform: translateY(-1px); }
.card-k { font-size: 12px; color: var(--muted); font-family: var(--mono); }
.card-t { font-weight: 650; font-size: 15.5px; line-height: 1.3; }
.card-d { font-size: 13px; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.card .chips { margin-top: auto; padding-top: 8px; }
.card.art { border-left: 3px solid var(--accent); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 10px 0; }
.card .chips { margin-bottom: 0; }
.chip { font-size: 12px; padding: 2px 9px; border-radius: 99px; background: var(--side); border: 1px solid var(--line); color: var(--text); max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip.accent { background: var(--accent-soft); border-color: transparent; color: var(--accent); font-weight: 600; }
.push { margin-left: auto; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 0 28px; }
.rows { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.row { display: flex; align-items: center; gap: 10px; padding: 9px 13px; color: var(--text); border-top: 1px solid var(--line); }
.row:first-child { border-top: 0; }
.row:hover { background: color-mix(in srgb, var(--accent) 6%, transparent); text-decoration: none; }
.row .ic { flex: none; width: 20px; text-align: center; }
.row-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.row-t { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-main .small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.more { display: inline-block; margin-top: 8px; font: inherit; font-size: 13px; background: none; border: 0; color: var(--accent); cursor: pointer; padding: 0; }

/* en-tete de document */
.crumbs { font-size: 13px; color: var(--muted); margin-bottom: 8px; overflow-wrap: anywhere; }
.crumbs a { color: var(--muted); } .crumbs b { color: var(--text); font-weight: 600; }
.sep { margin: 0 6px; opacity: .6; }
.bar { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 6px; }
.title { font-size: 23px; margin: 0 0 2px; letter-spacing: -.01em; overflow-wrap: anywhere; line-height: 1.25; }
.actions { display: flex; gap: 6px; flex-wrap: wrap; }
.btn { font: inherit; font-size: 13px; padding: 5px 11px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel); color: var(--text); cursor: pointer; white-space: nowrap; }
.btn:hover { border-color: var(--accent); text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.viewer { margin-top: 14px; }
.frame { width: 100%; height: calc(100dvh - var(--top) - 150px); min-height: 420px; border: 1px solid var(--line); border-radius: 12px; background: #fff; display: block; }
.imgbox { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 16px; text-align: center; }
.imgbox img { max-width: 100%; height: auto; }
.empty { background: var(--panel); border: 1px dashed var(--line); border-radius: 12px; padding: 28px; color: var(--muted); text-align: center; }

/* document markdown */
.doc { display: flex; gap: 34px; align-items: flex-start; }
.prose { flex: 1; min-width: 0; max-width: 820px; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 30px 38px 40px; box-shadow: var(--shadow); }
.prose.boxed { max-width: none; }
.toc { position: sticky; top: calc(var(--top) + 18px); width: 230px; flex: none; max-height: calc(100dvh - var(--top) - 40px); overflow: auto; font-size: 13px; border-left: 1px solid var(--line); padding-left: 14px; }
.toc-h { font-size: 11.5px; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); margin-bottom: 6px; font-weight: 600; }
.toc a { display: block; color: var(--muted); padding: 2.5px 0; line-height: 1.35; }
.toc a:hover { color: var(--accent); text-decoration: none; }
.toc .l1 { color: var(--text); font-weight: 600; } .toc .l3 { padding-left: 12px; font-size: 12.5px; }
.front { display: grid; grid-template-columns: max-content 1fr; gap: 3px 14px; font-size: 13px; background: var(--side); border-radius: 9px; padding: 10px 14px; margin: 0 0 22px; }
.front dt { color: var(--muted); font-family: var(--mono); font-size: 12px; } .front dd { margin: 0; overflow-wrap: anywhere; }

.md { font-size: 16px; line-height: 1.68; overflow-wrap: break-word; }
.md > :first-child { margin-top: 0; } .md > :last-child { margin-bottom: 0; }
.md h1, .md h2, .md h3, .md h4 { line-height: 1.28; margin: 1.7em 0 .55em; letter-spacing: -.01em; scroll-margin-top: calc(var(--top) + 14px); }
.md h1 { font-size: 1.75em; } .md h2 { font-size: 1.35em; padding-bottom: .3em; border-bottom: 1px solid var(--line); }
.md h3 { font-size: 1.13em; } .md h4 { font-size: 1em; color: var(--muted); }
.md p, .md ul, .md ol, .md blockquote, .md pre, .md .tablewrap { margin: 0 0 1em; }
.md ul, .md ol { padding-left: 1.5em; } .md li { margin: .2em 0; } .md li > p { margin-bottom: .4em; }
.md li:has(> input[type=checkbox]) { list-style: none; margin-left: -1.3em; }
.md blockquote { border-left: 3px solid var(--accent); padding: .1em 1em; color: var(--muted); background: var(--side); border-radius: 0 8px 8px 0; }
.md code { font-family: var(--mono); font-size: .86em; background: var(--code); padding: .14em .4em; border-radius: 5px; }
.md pre, pre.code { background: var(--code); border: 1px solid var(--line); border-radius: 10px; padding: 13px 15px; overflow: auto; font-size: 13px; line-height: 1.5; }
.md pre code, pre.code code { background: none !important; padding: 0 !important; font-family: var(--mono); font-size: inherit; }
pre.code { margin: 0; max-height: none; white-space: pre; tab-size: 2; }
.md hr { border: 0; border-top: 1px solid var(--line); margin: 2em 0; }
.md img { max-width: 100%; height: auto; border-radius: 8px; }
.tablewrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 10px; }
.md table { border-collapse: collapse; width: 100%; font-size: .9em; }
.md th, .md td { padding: 7px 11px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.md th { background: var(--side); font-weight: 600; white-space: nowrap; }
.md tr:last-child td { border-bottom: 0; }
mark { background: #ffe58a; color: #1f2328; border-radius: 3px; padding: 0 1px; }

/* session */
.thread { margin-top: 18px; max-width: 860px; display: flex; flex-direction: column; gap: 12px; }
.msg.user { background: var(--user); border-radius: 12px; padding: 11px 15px; border-left: 3px solid #5b8def; }
.who { font-size: 12.5px; font-weight: 700; margin-bottom: 3px; }
.utext { white-space: pre-wrap; overflow-wrap: anywhere; }
.msg.bot { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 13px 17px; }
.msg.bot .md { font-size: 15px; }
.msg.artlink { display: block; background: var(--accent-soft); border-radius: 10px; padding: 9px 14px; }
.tools { font-size: 13px; color: var(--muted); max-width: 860px; }
.tools summary { cursor: pointer; padding: 3px 0; color: var(--text); }
.tools ul { margin: 6px 0 4px; padding-left: 20px; } .tools li { margin: 3px 0; overflow-wrap: anywhere; }
.tools b { color: var(--text); font-weight: 600; }
.cmd { font-family: var(--mono); font-size: 11.5px; background: var(--code); border-radius: 6px; padding: 6px 8px; margin: 4px 0; white-space: pre-wrap; overflow-wrap: anywhere; max-height: 180px; overflow: auto; }

/* recherche */
.hit { display: block; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 9px 13px; margin-bottom: 8px; color: var(--text); }
.hit:hover { border-color: var(--accent); text-decoration: none; }
.hit-f { font-size: 13px; margin-bottom: 4px; overflow-wrap: anywhere; }
.hit-l { font-size: 12.5px; font-family: var(--mono); color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ln { display: inline-block; min-width: 34px; opacity: .6; }

@media (max-width: 1180px) { .toc { display: none; } }
@media (max-width: 860px) {
  body { font-size: 15px; }
  #side { position: fixed; left: 0; top: var(--top); z-index: 25; width: min(86vw, 330px); transform: translateX(-102%); transition: transform .18s ease; box-shadow: 4px 0 24px rgba(0,0,0,.18); }
  .side-open #side { transform: none; }
  .side-open #scrim { display: block; position: fixed; inset: var(--top) 0 0 0; z-index: 20; background: rgba(0,0,0,.35); }
  #nav a { padding: 6px 7px; font-size: 13.5px; }
  #nav a[data-nav=home] { display: none; }
  #top { gap: 6px; }
  .brand { font-size: 0; } .brand .logo { font-size: 20px; }
  .page { padding: 16px 14px 70px; }
  .page.wide { padding: 12px 10px 10px; }
  .prose { padding: 20px 18px 26px; border-radius: 12px; }
  .two { grid-template-columns: 1fr; }
  .grid { grid-template-columns: 1fr; }
  .title { font-size: 20px; }
  .frame { height: calc(100dvh - var(--top) - 190px); }
  .tree, .leaf, .tree summary { font-size: 14.5px; } .leaf, .tree details > summary { padding-top: 6px; padding-bottom: 6px; }
}
@media (min-width: 861px) { #menu { display: none !important; } }

/* etat tmux */
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: #2fa866; margin-right: 7px; vertical-align: 1px; flex: none; }
.tmux { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 9px 13px; margin: 10px 0; max-width: 860px; font-size: 14px; }
.tmux .dot { margin-right: 0; }
.tmux code { font-family: var(--mono); font-size: 12.5px; background: var(--code); padding: 3px 8px; border-radius: 6px; }
.err { color: #c0392b; font-size: 13px; }

.dot.off { background: var(--line); }
div.row:hover { background: none; }
.row .btn { flex: none; }
.dlg { border: 1px solid var(--line); border-radius: 14px; background: var(--panel); color: var(--text); padding: 22px 24px; width: min(440px, calc(100vw - 28px)); box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.dlg::backdrop { background: rgba(0,0,0,.45); }
.dlg h2 { margin: 0 0 14px; font-size: 18px; }
.dlg label { display: block; font-size: 13px; color: var(--muted); margin: 12px 0 0; }
.dlg label.inline { color: var(--text); font-size: 14px; }
.dlg select, .dlg input[type=text], .dlg textarea { display: block; width: 100%; margin-top: 5px; font: inherit; font-size: 16px; color: var(--text); background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; }
.dlg input[type=text]:focus, .dlg select:focus, .dlg textarea:focus { outline: none; border-color: var(--accent); }
.dlg-b { display: flex; gap: 8px; margin-top: 18px; }
.dlg code { font-family: var(--mono); font-size: 12.5px; background: var(--code); padding: 2px 6px; border-radius: 5px; }
.btn:disabled { opacity: .6; cursor: default; }
.dlg textarea { resize: vertical; line-height: 1.4; }
