.nav-links a.active {
  color: var(--green);
}

.notes-body {
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  --sidebar-w: 280px;
}

.notes-layout {
  flex: 1;
  min-height: 0;
  min-width: 0;
  display: flex;
  position: relative;
  max-width: 1400px;
  width: 100%;
  margin: 0 auto;
  padding: 90px clamp(16px, 3vw, 40px) 24px;
}

/* Le fond du tiroir n'existe qu'en mode mobile (voir media query plus bas) :
   display:none par défaut pour qu'il ne puisse jamais recouvrir le bureau,
   même si .open reste posé après un redimensionnement de fenêtre. */
.notes-backdrop {
  display: none;
}

/* SIDEBAR */
.notes-sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.notes-sidebar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.notes-close {
  display: none;
  background: none;
  border: 1px solid var(--border);
  color: var(--text-dim);
  font-family: var(--font);
  font-size: 13px;
  line-height: 1;
  padding: 4px 8px;
  cursor: pointer;
}

.notes-close:hover {
  color: var(--green);
  border-color: var(--green);
}

/* RESIZER (desktop drag handle) */
.notes-resizer {
  flex-shrink: 0;
  width: 17px;
  margin: 0 -8px;
  position: relative;
  z-index: 5;
  cursor: col-resize;
}

.notes-resizer::after {
  content: '';
  position: absolute;
  left: 50%;
  top: 0;
  bottom: 0;
  width: 1px;
  background: var(--border);
  transform: translateX(-50%);
  transition: background 0.15s, width 0.15s;
}

.notes-resizer:hover::after,
.notes-resizer.dragging::after {
  width: 2px;
  background: var(--green);
}

.notes-main {
  flex: 1;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding-left: 16px;
}

.notes-menu-btn {
  display: none;
}

.notes-search {
  width: 100%;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text);
  font-family: var(--font);
  font-size: 13px;
  padding: 8px 10px;
  margin: 10px 0;
  outline: none;
}

.notes-search:focus {
  border-color: var(--green);
}

.notes-count {
  color: var(--text-dim);
  font-size: 11px;
  margin-bottom: 10px;
}

.notes-tree {
  overflow-y: auto;
  flex: 1;
  min-height: 0;
  padding-right: 6px;
}

.tree-list {
  list-style: none;
  padding-left: 14px;
}

.notes-tree > .tree-list {
  padding-left: 0;
}

.tree-folder > details > summary {
  cursor: pointer;
  color: var(--cyan);
  font-size: 13px;
  padding: 4px 0;
  list-style: none;
}

.tree-folder > details > summary::-webkit-details-marker {
  display: none;
}

.tree-folder > details > summary::before {
  content: '▸ ';
  color: var(--text-dim);
}

.tree-folder > details[open] > summary::before {
  content: '▾ ';
}

.tree-file a {
  display: block;
  color: var(--text-dim);
  text-decoration: none;
  font-size: 13px;
  padding: 3px 0 3px 4px;
  border-left: 1px solid transparent;
}

.tree-file a:hover {
  color: var(--text);
}

.tree-file a.active {
  color: var(--green);
  border-left-color: var(--green);
  padding-left: 8px;
}

/* CONTENT */
.notes-content {
  flex: 1;
  min-width: 0;
  min-height: 0;
  overflow-y: auto;
  border: 1px solid var(--border);
  background: var(--bg-card);
  padding: 32px clamp(20px, 4vw, 48px);
}

.notes-body footer {
  flex-shrink: 0;
}

.notes-placeholder .about-text {
  margin-top: 14px;
}

.notes-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 14px 0 24px;
}

/* MARKDOWN BODY */
.markdown-body {
  color: var(--text);
  font-size: 14px;
  line-height: 1.8;
  max-width: 780px;
}

.markdown-body h1,
.markdown-body h2,
.markdown-body h3 {
  color: var(--text);
  font-weight: 400;
  margin: 28px 0 14px;
  line-height: 1.4;
}

.markdown-body h1 { font-size: 22px; color: var(--green); }
.markdown-body h2 { font-size: 18px; border-top: 1px solid var(--border); padding-top: 20px; }
.markdown-body h3 { font-size: 15px; color: var(--cyan); }

.markdown-body h1:first-child,
.markdown-body h2:first-child {
  margin-top: 0;
  border-top: none;
  padding-top: 0;
}

.markdown-body p {
  margin: 12px 0;
  color: var(--text-dim);
}

.markdown-body strong {
  color: var(--text);
  font-weight: 600;
}

.markdown-body a,
.markdown-body a.wikilink {
  color: var(--cyan);
  text-decoration: none;
  border-bottom: 1px dashed var(--border);
}

.markdown-body a:hover {
  color: var(--green);
  border-bottom-color: var(--green);
}

.wikilink-missing {
  color: var(--text-dim);
  border-bottom: 1px dotted var(--text-dim);
  opacity: 0.6;
}

.wikilink-folder {
  color: var(--text-dim);
  font-style: italic;
}

.markdown-body ul,
.markdown-body ol {
  margin: 12px 0 12px 22px;
  color: var(--text-dim);
}

.markdown-body li {
  margin: 4px 0;
}

.markdown-body blockquote {
  border-left: 2px solid var(--green);
  padding: 4px 16px;
  margin: 16px 0;
  color: var(--text-dim);
  font-size: 13px;
  background: rgba(0, 255, 65, 0.03);
}

.markdown-body code {
  font-family: var(--font);
  background: var(--bg);
  border: 1px solid var(--border);
  padding: 1px 5px;
  font-size: 13px;
  color: var(--green);
}

.markdown-body pre {
  background: var(--bg);
  border: 1px solid var(--border);
  padding: 16px;
  overflow-x: auto;
  margin: 16px 0;
}

.markdown-body pre code {
  border: none;
  padding: 0;
  background: none;
  color: var(--text);
}

.markdown-body table {
  border-collapse: collapse;
  width: 100%;
  margin: 16px 0;
  font-size: 13px;
}

.markdown-body th,
.markdown-body td {
  border: 1px solid var(--border);
  padding: 8px 10px;
  text-align: left;
  color: var(--text-dim);
}

.markdown-body th {
  color: var(--text);
  background: var(--bg);
}

.markdown-body hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 24px 0;
}

.markdown-body img {
  max-width: 100%;
}

/* RESPONSIVE */

/* Tablette / mobile : l'arborescence devient un tiroir coulissant,
   le contenu garde tout l'écran et son propre scroll interne. */
@media (max-width: 760px) {
  .notes-layout {
    padding-left: 16px;
    padding-right: 16px;
  }

  .notes-resizer {
    display: none;
  }

  .notes-main {
    padding-left: 0;
  }

  .notes-menu-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    align-self: flex-start;
    flex-shrink: 0;
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text-dim);
    font-family: var(--font);
    font-size: 12px;
    letter-spacing: 1px;
    padding: 8px 14px;
    margin-bottom: 12px;
    cursor: pointer;
  }

  .notes-menu-btn:hover,
  .notes-menu-btn:active {
    color: var(--green);
    border-color: var(--green);
  }

  .notes-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: min(84vw, 340px);
    background: var(--bg-card);
    border-right: 1px solid var(--border);
    padding: 84px 16px 16px;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    z-index: 200;
  }

  .notes-sidebar.open {
    transform: translateX(0);
  }

  .notes-close {
    display: block;
  }

  .notes-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 150;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
  }

  .notes-backdrop.open {
    opacity: 1;
    pointer-events: auto;
  }
}

/* Très petit écran : marge de lecture réduite */
@media (max-width: 480px) {
  .notes-content {
    padding: 24px 18px;
  }

  .notes-sidebar {
    width: 88vw;
  }
}
