/*
 * Style volontairement minimal : noir, blanc, rien d'autre. Pas de verre,
 * pas de dégradé, pas de flou, pas de couleur d'accent. Seules les règles
 * de typographie (tracking/interligne selon la taille) et d'accessibilité
 * du skill `apple-design` sont conservées — elles servent la lisibilité,
 * pas la décoration.
 */

:root {
  --bg: #000000;
  --surface: rgba(0, 0, 0, 0.92); /* laisse deviner le fond derrière, à peine */
  --border: #4d4d4d;
  --border-hi: #808080;
  --text: #ffffff;
  --text-dim: #999999;
  --text-faint: #666666;
  --danger: #ff5c5c;
  --hover: #1a1a1a;
  --active: #262626;

  --radius-panel: 12px;
  --radius-pill: 999px;

  /* Playfair Display réservée aux gros titres (ses jambages fins la rendent
     illisible en dessous d'environ 20px) ; Lora pour tout le reste du texte
     — même famille d'esprit "sérif classique", pensée pour rester lisible. */
  --font-ui: 'Lora', Georgia, 'Times New Roman', serif;
  --font-display: 'Playfair Display', Georgia, 'Times New Roman', serif;
  --font-mono: 'JetBrains Mono', ui-monospace, 'SF Mono', Consolas, monospace;
  --titlebar-h: 40px;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
}

* { box-sizing: border-box; }

/* Surlignage de texte : fond blanc, texte noir (au lieu du bleu par défaut). */
::selection { background: #fff; color: #000; }

html, body {
  height: 100%;
  height: 100dvh;
  margin: 0;
  background: var(--bg) 62% center / cover no-repeat fixed;
  background-image: url('bg-landscape.jpg');
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
  user-select: none;
}
/* Portrait (téléphone) vs paysage (PC) : deux cadrages différents de la
   même image, pas juste la même recadrée bêtement. */
@media (orientation: portrait) {
  html, body { background-image: url('bg-portrait.jpg'); }
}

button {
  font-family: inherit;
  cursor: pointer;
  color: inherit;
  background: none;
  border: none;
  -webkit-tap-highlight-color: transparent;
}

input {
  font-family: inherit;
  color: var(--text);
  background: transparent;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  -webkit-tap-highlight-color: transparent;
}

.hidden { display: none !important; }
.dim { color: var(--text-dim); }

/* ---------- Title bar ---------- */
#titlebar {
  height: var(--titlebar-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg);
  border-bottom: 1.5px solid var(--border);
  -webkit-app-region: drag;
}
body:not(.is-electron) #titlebar { display: none; }
body:not(.is-electron) { --titlebar-h: 0px; }

#titlebar-drag {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-left: 14px;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.01em;
  color: var(--text-dim);
}
/* Boutons de la barre de titre (masquer la liste, déconnexion) : carrés,
   proportionnés comme les boutons de fenêtre (−, □, ✕) à côté desquels ils
   vivent, pas des petites icônes perdues. */
.titlebar-icon-btn {
  -webkit-app-region: no-drag;
  flex: none;
  box-sizing: border-box;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 7px;
  color: var(--text-faint);
  transition: background-color 120ms var(--ease), color 120ms var(--ease);
}
.titlebar-icon-btn:hover { background: var(--hover); color: var(--text); }
/* Une seule des deux copies à la fois : celle de la barre de titre en
   appli de bureau, celle de l'en-tête de liste sur le web. */
body:not(.is-electron) #btn-toggle-sidebar-titlebar,
body:not(.is-electron) #btn-logout-titlebar { display: none; }
body.is-electron #btn-toggle-sidebar-header,
body.is-electron #btn-logout { display: none; }
#titlebar-controls { display: flex; -webkit-app-region: no-drag; }
#titlebar-controls button {
  width: 46px;
  height: var(--titlebar-h);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  line-height: 1;
  color: var(--text-dim);
  transition: background-color 120ms var(--ease), color 120ms var(--ease);
}
#titlebar-controls button:hover { background: var(--hover); color: var(--text); }
#titlebar-controls button:active { background: var(--active); }
#btn-close:hover { background: var(--danger) !important; color: #fff !important; }

/* ---------- App shell ---------- */
#app { height: calc(100% - var(--titlebar-h)); }

/* ---------- Login ---------- */
#login-screen {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
/* ---------- Logo de l'épée (sobre, pas d'effet raté) ---------- */
.tilt-wrap {
  width: 96px;
  height: 96px;
  margin: 0 auto 14px;
}
.tilt-wrap-empty { width: 120px; height: 120px; margin-bottom: 18px; opacity: 0.85; }
.tilt-card {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: 14px;
  transition: transform 200ms var(--ease);
}
.tilt-wrap:hover .tilt-card { transform: scale(1.05); }
.tilt-sheen { display: none; }
.login-card {
  width: 320px;
  padding: 34px 30px;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-panel);
  text-align: center;
}
.login-card h1 { margin: 0 0 4px; font-family: var(--font-display); font-size: 23px; font-weight: 700; letter-spacing: -0.012em; }
.login-card p { margin: 0 0 22px; font-size: 13px; letter-spacing: 0.005em; }
#login-form { display: flex; flex-direction: column; gap: 10px; }
#login-form input { padding: 11px 16px; font-size: 13px; transition: border-color 150ms var(--ease); }
#login-form input:focus { outline: none; border-color: var(--text); }
#login-form button {
  margin-top: 6px;
  padding: 11px;
  background: #fff;
  color: #000;
  border-radius: 8px;
  font-weight: 600;
  font-size: 13px;
  letter-spacing: 0.01em;
  transition: transform 100ms ease-out, opacity 150ms var(--ease);
}
#login-form button:hover { opacity: 0.85; }
#login-form button:active { transform: scale(0.97); }
.error { color: var(--danger); font-size: 12.5px; margin-top: 12px; }
.link-btn {
  display: block;
  width: 100%;
  margin-top: 16px;
  font-size: 12px;
  letter-spacing: 0.01em;
  color: var(--text-dim);
  text-align: center;
  transition: color 120ms var(--ease);
}
.link-btn:hover { color: var(--text); }

/* ---------- Layout ---------- */
#main-layout {
  display: flex;
  height: 100%;
}

/* ---------- Sidebar ---------- */
#sidebar {
  width: 260px;
  min-width: 180px;
  max-width: 480px;
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1.5px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Poignée de redimensionnement, entre la barre latérale et l'éditeur */
#sidebar-resizer {
  flex-shrink: 0;
  width: 5px;
  margin: 0 -2px;
  cursor: col-resize;
  position: relative;
  z-index: 1;
}
#sidebar-resizer:hover, #sidebar-resizer:active { background: var(--border-hi); }

/* Masquer/afficher la barre latérale (mode "feuille seule") */
#main-layout.sidebar-collapsed #sidebar,
#main-layout.sidebar-collapsed #sidebar-resizer {
  display: none;
}
#sidebar-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: max(14px, env(safe-area-inset-top)) 14px 10px;
}
#search-input {
  flex: 1;
  min-width: 0;
  width: auto;
  padding: 10px 14px;
  font-size: 15px;
  letter-spacing: 0.005em;
  border-radius: var(--radius-pill);
}
#search-input:focus { outline: none; border-color: var(--text); }

/* Boutons ronds de l'en-tête : cible tactile confortable (44px), jamais
   coincés en bas ni coupés par la zone sûre. */
.icon-btn {
  flex-shrink: 0;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-dim);
  background: transparent;
  border: 1.5px solid var(--border);
  transition: background-color 150ms var(--ease), color 150ms var(--ease), transform 100ms ease-out;
}
.icon-btn:hover { color: var(--text); border-color: var(--border-hi); background: var(--hover); }
.icon-btn:active { transform: scale(0.9); }
#btn-logout.offline, #btn-logout-titlebar.offline { color: var(--danger); border-color: var(--danger); }

#page-tree {
  flex: 1;
  overflow-y: auto;
  padding: 4px 10px max(10px, env(safe-area-inset-bottom));
}
#page-tree::-webkit-scrollbar { width: 8px; }
#page-tree::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

.tree-row {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 7px 10px;
  border-radius: 8px;
  cursor: pointer;
  position: relative;
  transition: background-color 140ms var(--ease);
  /* Sans ça, Safari mobile attend un peu après le premier tap pour voir si
     un second arrive (zoom par double-tap) — un tap simple doit ouvrir la
     page tout de suite, pas au bout de deux essais. */
  touch-action: manipulation;
}
.tree-row:hover { background: var(--hover); }
.tree-row:active { transform: scale(0.985); transition: transform 100ms ease-out; }
.tree-row.selected { background: var(--active); }
.tree-row.dragging-source { opacity: 0.4; }
.tree-row.drop-target { background: var(--hover); outline: 1.5px dashed #fff; outline-offset: -2px; }
.tree-row.drop-line-before, .tree-row.drop-line-after { position: relative; }
.tree-row.drop-line-before::before, .tree-row.drop-line-after::after {
  content: "";
  position: absolute;
  left: 8px; right: 8px;
  height: 2px;
  background: #fff;
  border-radius: 1px;
}
.tree-row.drop-line-before::before { top: -1px; }
.tree-row.drop-line-after::after { bottom: -1px; }
.tree-drag-ghost {
  position: fixed;
  z-index: 3000;
  padding: 6px 12px;
  border-radius: 8px;
  background: #fff;
  color: #000;
  font-size: 12.5px;
  font-family: var(--font-ui);
  font-weight: 600;
  pointer-events: none;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.5);
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.tree-row.selected .tree-title { color: var(--text); font-weight: 600; }
.tree-row.selected::before {
  content: "";
  position: absolute;
  left: -6px; top: 6px; bottom: 6px;
  width: 3px;
  background: #fff;
  border-radius: 2px;
}
.tree-caret {
  width: 16px;
  text-align: center;
  color: var(--text-faint);
  font-size: 10px;
  flex-shrink: 0;
  transition: transform 180ms var(--ease);
}
.tree-caret.empty { visibility: hidden; }
.tree-icon {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  color: var(--text-faint);
}
.tree-row.selected .tree-icon { color: var(--text-dim); }
.tree-title {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-dim);
  font-size: 13px;
  letter-spacing: 0.005em;
}
.tree-rename-input {
  flex: 1;
  min-width: 0;
  padding: 2px 6px;
  font-size: 13px;
  letter-spacing: 0.005em;
  border-radius: 5px;
}
/* Le conteneur reste toujours en place (sinon impossible de garder
   l'épingle visible hors survol) ; seuls + et × se cachent hors survol. */
.tree-row-actions { display: flex; gap: 2px; flex-shrink: 0; }
.tree-row-actions .add-btn, .tree-row-actions .del-btn { display: none; }
.tree-row:hover .tree-row-actions .add-btn, .tree-row:hover .tree-row-actions .del-btn { display: flex; }
.tree-row-actions button {
  width: 22px; height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-pill);
  color: var(--text-faint);
  font-size: 13px;
  line-height: 22px;
  transition: background-color 120ms var(--ease), color 120ms var(--ease), transform 100ms ease-out, opacity 120ms var(--ease);
}
.tree-row-actions button:hover { background: var(--hover); color: var(--text); }
.tree-row-actions button:active { transform: scale(0.9); }
.pin-btn { opacity: 0; }
.tree-row:hover .pin-btn, .pin-btn.pinned { opacity: 1; }
.pin-btn.pinned { color: #fff; }

/* ---------- Editor area ---------- */
#editor-area {
  flex: 1;
  min-width: 0;
  position: relative;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  overflow: hidden;
}

#empty-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: var(--text-faint);
  text-align: center;
}
#empty-state h2 { font-size: 14px; font-weight: 500; letter-spacing: 0.005em; margin: 0; max-width: 300px; }
#empty-state button {
  margin-top: 6px;
  padding: 9px 18px;
  border-radius: var(--radius-pill);
  border: 1.5px solid var(--border);
  color: var(--text);
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: 0.01em;
  transition: background-color 150ms var(--ease), transform 100ms ease-out;
}
#empty-state button:hover { background: var(--hover); }
#empty-state button:active { transform: scale(0.96); }

#page-view {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

/* Barre d'outils */
#toolbar {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 16px;
  padding-top: max(10px, env(safe-area-inset-top));
  background: var(--surface);
  border-bottom: 1.5px solid var(--border);
  -webkit-app-region: drag;
}
#btn-back-mobile {
  -webkit-app-region: no-drag;
  flex-shrink: 0;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-dim);
  transition: background-color 140ms var(--ease), color 140ms var(--ease), transform 100ms ease-out;
}
#btn-back-mobile:hover { background: var(--hover); color: var(--text); }
#btn-back-mobile:active { transform: scale(0.9); }

/* Une seule barre continue, en ligne, qui défile horizontalement au besoin. */
#toolbar-scroll {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 1px;
  padding: 3px;
  border-radius: var(--radius-pill);
  border: 1.5px solid var(--border);
  overflow-x: auto;
  scrollbar-width: none;
}
#toolbar-scroll::-webkit-scrollbar { display: none; }

#toolbar button {
  -webkit-app-region: no-drag;
  flex-shrink: 0;
}
#toolbar-scroll button {
  min-width: 34px;
  height: 34px;
  padding: 0 11px;
  border-radius: var(--radius-pill);
  font-size: 12.5px;
  letter-spacing: 0.01em;
  color: var(--text-dim);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 140ms var(--ease), color 140ms var(--ease), transform 100ms ease-out;
}
#toolbar-scroll button:hover { background: var(--hover); color: var(--text); }
#toolbar-scroll button:active { transform: scale(0.9); }
#toolbar-scroll button.active { background: #fff; color: #000; }
.toolbar-sep { width: 1px; height: 18px; background: var(--border); margin: 0 5px; flex-shrink: 0; }
.toolbar-spacer { flex-shrink: 0; width: 10px; }
#btn-delete-page {
  flex-shrink: 0;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-faint);
  transition: background-color 140ms var(--ease), color 140ms var(--ease), transform 100ms ease-out;
}
#btn-delete-page:hover { background: var(--danger); color: #fff; }
#btn-delete-page:active { transform: scale(0.9); }

#page-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 34px 0 120px;
  user-select: text;
}
#page-scroll::-webkit-scrollbar { width: 8px; }
#page-scroll::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

#page-header, #page-content {
  max-width: 760px;
  margin: 0 auto;
  padding: 0 44px;
}

#page-title {
  font-family: var(--font-display);
  font-size: 31px;
  font-weight: 800;
  line-height: 1.15;
  letter-spacing: -0.022em;
  outline: none;
}
#page-title:empty::before,
#page-content:empty::before {
  content: attr(data-placeholder);
  color: var(--text-faint);
}
/* Caché par défaut : cette info n'a pas besoin de prendre de la place en
   permanence sous chaque titre — elle apparaît juste au survol. */
#page-meta {
  margin: 7px 0 26px;
  font-size: 12px;
  letter-spacing: 0.01em;
  color: var(--text-faint);
  opacity: 0;
  transition: opacity 150ms var(--ease);
}
#page-header:hover #page-meta { opacity: 1; }

#page-content {
  /* position + z-index (même à 0) crée une vraie bulle d'empilement propre
     à cette zone : une image "envoyée à l'arrière-plan" reste coincée
     derrière le texte de la note, elle ne peut plus s'échapper et finir
     cachée derrière des panneaux entiers de l'appli. */
  position: relative;
  z-index: 0;
  min-height: 300px;
  outline: none;
  line-height: 1.7;
  font-size: 15.5px;
  letter-spacing: 0;
}

/* ---------- Images flottantes (déplacer / redimensionner / empiler) ---------- */
.float-img {
  position: absolute;
  box-sizing: border-box;
  cursor: grab;
  touch-action: none;
}
.float-img.dragging { cursor: grabbing; }
.float-img img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: 6px;
  border: 1.5px solid var(--border);
  pointer-events: none; /* le déplacement passe par le conteneur, pas l'image elle-même */
  background: #0d0d0d;
}
/* Invisibles en permanence (y compris pendant le glisser) — la zone reste
   fonctionnelle pour attraper un coin, juste sans affichage à l'écran. */
.float-img-handle {
  position: absolute;
  width: 14px;
  height: 14px;
  opacity: 0;
}
.float-img-handle[data-handle="nw"] { left: -7px; top: -7px; cursor: nwse-resize; }
.float-img-handle[data-handle="ne"] { right: -7px; top: -7px; cursor: nesw-resize; }
.float-img-handle[data-handle="sw"] { left: -7px; bottom: -7px; cursor: nesw-resize; }
.float-img-handle[data-handle="se"] { right: -7px; bottom: -7px; cursor: nwse-resize; }

.float-img-menu {
  position: fixed;
  z-index: 1000;
  background: #000;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  padding: 5px;
  min-width: 190px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.6);
}
.float-img-menu button {
  display: block;
  width: 100%;
  text-align: left;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 13px;
  font-family: var(--font-ui);
  color: var(--text);
  transition: background-color 120ms var(--ease);
}
.float-img-menu button:hover { background: var(--hover); }
.float-img-menu hr { border: none; border-top: 1.5px solid var(--border); margin: 4px 2px; }

/* ---------- Boîte de dialogue maison ---------- */
#dialog-overlay {
  position: fixed;
  inset: 0;
  z-index: 2000;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
#dialog-box {
  width: 340px;
  max-width: 100%;
  padding: 24px;
  background: #000;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-panel);
}
#dialog-message {
  margin: 0 0 20px;
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
}
#dialog-actions { display: flex; justify-content: flex-end; gap: 10px; }
#dialog-actions button {
  padding: 9px 16px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.01em;
}
.link-btn-inline { color: var(--text-dim); transition: color 120ms var(--ease); }
.link-btn-inline:hover { color: var(--text); }
#dialog-confirm { background: #fff; color: #000; }
#dialog-confirm:hover { opacity: 0.85; }
#dialog-confirm.danger { background: var(--danger); color: #fff; }

/* ---------- Menu contextuel (clic droit / appui long sur une page/dossier) ---------- */
.ctx-menu {
  position: fixed;
  z-index: 1000;
  background: #000;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  padding: 5px;
  min-width: 190px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.6);
}
.ctx-menu button {
  display: block;
  width: 100%;
  text-align: left;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 13px;
  font-family: var(--font-ui);
  color: var(--text);
  transition: background-color 120ms var(--ease);
}
.ctx-menu button:hover { background: var(--hover); }
.ctx-menu hr { border: none; border-top: 1.5px solid var(--border); margin: 4px 2px; }

/* ---------- Boîte "Déplacer vers…" ---------- */
#move-overlay {
  position: fixed;
  inset: 0;
  z-index: 2000;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
#move-box {
  width: 320px;
  max-width: 100%;
  max-height: 70vh;
  display: flex;
  flex-direction: column;
  padding: 20px;
  background: #000;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-panel);
}
#move-title { margin: 0 0 14px; font-size: 14px; font-weight: 600; color: var(--text); }
#move-list { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 2px; margin-bottom: 12px; }
.move-option {
  text-align: left;
  padding: 9px 10px;
  border-radius: 6px;
  font-size: 13px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: background-color 120ms var(--ease);
}
.move-option:hover { background: var(--hover); }
#move-cancel { align-self: flex-end; padding: 8px 4px; }
#page-content h1 { font-family: var(--font-display); font-weight: 700; font-size: 24px; line-height: 1.2; letter-spacing: -0.016em; margin: 28px 0 10px; }
#page-content h2 { font-weight: 700; font-size: 19px; line-height: 1.3; letter-spacing: -0.008em; margin: 22px 0 8px; color: var(--text); }
#page-content p { margin: 0 0 10px; }
#page-content ul { padding-left: 22px; margin: 0 0 10px; }
#page-content blockquote {
  margin: 14px 0;
  padding: 6px 18px;
  border-left: 3px solid #fff;
  color: var(--text-dim);
}
#page-content pre {
  background: #0d0d0d;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  padding: 14px 16px;
  font-family: var(--font-mono);
  font-size: 13px;
  letter-spacing: 0;
  overflow-x: auto;
  white-space: pre-wrap;
}
#page-content img {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 14px 0;
  border-radius: 8px;
  border: 1.5px solid var(--border);
}
#page-content .checklist-item {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  margin: 5px 0;
  /* Imbrication purement visuelle (Tab / Maj+Tab) : toutes les cases sont
     des éléments frères à plat, seule l'indentation change. */
  padding-left: calc(var(--depth, 0) * 22px);
}
#page-content .checklist-item input {
  margin-top: 4px;
  flex-shrink: 0;
  accent-color: #fff;
  border-radius: 5px;
  width: 15px;
  height: 15px;
}
#page-content .checklist-item.checked span { color: var(--text-faint); text-decoration: line-through; }

/* Dans la barre d'outils elle-même (pas flottant en bas de l'écran) :
   sur iPhone, le clavier recouvre tout le bas de l'écran pendant qu'on
   écrit — exactement le moment où cet indicateur doit apparaître. */
#save-indicator {
  flex-shrink: 0;
  font-size: 11.5px;
  letter-spacing: 0.01em;
  color: var(--text-dim);
  opacity: 0;
  transition: opacity 200ms var(--ease);
  pointer-events: none;
}
#save-indicator.show { opacity: 1; }

#btn-back-mobile { display: none; }

/* ---------- Responsive (phone) ---------- */
@media (max-width: 720px) {
  html, body { user-select: text; }
  /* Fond plus visible sur téléphone que sur PC (deux réglages distincts). */
  :root { --surface: rgba(0, 0, 0, 0.8); }
  /* Plein écran, bord à bord — pas de marge flottante sur téléphone. */
  #main-layout { flex-direction: column; }
  /* Redimensionner/masquer la barre latérale n'a pas de sens sur téléphone
     (elle prend déjà tout l'écran, en plein ou pas du tout). */
  #sidebar-resizer, #btn-toggle-sidebar-titlebar, #btn-toggle-sidebar-header { display: none; }
  #main-layout.sidebar-collapsed #sidebar { display: flex; }
  #sidebar {
    width: 100% !important; /* prime sur une largeur mémorisée en style inline depuis le PC */
    min-width: 0;
    flex: 1;
    border-right: none;
  }
  body:not(.showing-page) #editor-area { display: none; }
  body.showing-page #sidebar { display: none; }
  #btn-back-mobile { display: inline-flex; margin-right: 2px; }
  #page-header, #page-content { padding: 0 20px; }
  #toolbar { padding: 10px 14px; }
  #page-scroll { padding-bottom: max(120px, calc(80px + env(safe-area-inset-bottom))); }

  /* Empêche le zoom automatique de Safari iOS : il se déclenche dès qu'un
     champ éditable a un texte de moins de 16px au moment du focus. */
  #search-input,
  #login-form input,
  #page-content {
    font-size: 16px;
  }
}

/* ---------- Accessibilité : mouvement, contraste renforcé ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 120ms !important;
  }
  .tree-row:active, #toolbar-scroll button:active, .login-card button:active,
  #empty-state button:active, .tree-row-actions button:active, .icon-btn:active,
  #btn-back-mobile:active, #btn-delete-page:active {
    transform: none !important;
  }
}

@media (prefers-contrast: more) {
  #sidebar, #editor-area, .login-card, #save-indicator, #btn-new-root-page, #search-input,
  #login-form input, .icon-btn, #toolbar-scroll, #toolbar {
    border-color: #fff;
  }
}
