:root {
  --page: #e3e5e1;
  --surface: #f0f1ee;
  --ink: #14213d;
  --muted: #5b6575;
  --accent: #2a5bc4;
  --accent-ink: #ffffff;
  --rule: #c5c9c3;
  --mark: #ffd84d;
  --display: "Archivo", "Helvetica Neue", Arial, sans-serif;
  --text: "Source Serif 4", Georgia, "Times New Roman", serif;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --page: #10151f;
    --surface: #171e2b;
    --ink: #e7eaf0;
    --muted: #94a0b4;
    --accent: #7fa2f0;
    --accent-ink: #10151f;
    --rule: #2b3548;
    --mark: #8a6d00;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; -webkit-tap-highlight-color: transparent; }
button, a, input { touch-action: manipulation; }
body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font: 400 1.0625rem/1.6 var(--text);
}
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: 16px; top: -60px; padding: 10px 14px; background: var(--accent); color: var(--accent-ink); font: 600 .95rem var(--display); z-index: 10; }
.skip:focus { top: 12px; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
a { color: inherit; }

/* ---------- structure ---------- */
.shell { padding-inline: env(safe-area-inset-left) env(safe-area-inset-right); display: grid; grid-template-columns: 280px minmax(0, 1fr); max-width: 1160px; margin: 0 auto; }
.rail {
  position: sticky; top: 0; align-self: start; height: 100vh; height: 100dvh; overflow-y: auto;
  padding: 36px 24px 32px 32px; display: flex; flex-direction: column; gap: 28px;
}
main { padding: 48px 40px 120px 48px; min-width: 0; outline: none; }

.top { display: flex; flex-direction: column; gap: 28px; }
.stub .t { display: none; }
.brand { text-decoration: none; font: 800 1.35rem/1 var(--display); font-stretch: 125%; letter-spacing: -.01em; }
.search input {
  width: 100%; padding: 13px 14px; font: 500 1rem var(--display);
  background: var(--surface); color: var(--ink); border: 1px solid var(--rule); border-radius: 4px;
}
.search input::placeholder { color: var(--muted); }

/* ---------- index des rubriques ---------- */
.track { position: relative; }
#index { list-style: none; margin: 0; padding: 0; border-left: 1px solid var(--rule); }
#index a {
  display: flex; justify-content: space-between; align-items: baseline; gap: 12px;
  padding: 9px 4px 9px 18px; text-decoration: none; color: var(--muted);
  font: 600 1rem/1.25 var(--display);
}
#index a:hover { color: var(--ink); }
#index a[aria-current="page"] { color: var(--ink); }
#index .n { font-weight: 500; font-size: .875rem; font-variant-numeric: tabular-nums; }
.marker {
  position: absolute; left: -2px; top: 0; width: 3px; height: var(--mh, 0); background: var(--accent);
  transform: translateY(var(--my, 0)); transition: transform .28s cubic-bezier(.3, .7, .2, 1), height .28s cubic-bezier(.3, .7, .2, 1);
}

/* ---------- en-tête de page ---------- */
.head { padding-bottom: 26px; border-bottom: 3px solid var(--ink); }
.head h1 {
  margin: 0; font: 800 clamp(2.2rem, 6vw, 3.9rem)/1.02 var(--display); font-stretch: 125%; letter-spacing: -.015em;
  overflow-wrap: anywhere; text-wrap: balance;
}
.head h1.compact { font-size: clamp(1.7rem, 4.5vw, 2.6rem); }
.head p { margin: 14px 0 0; color: var(--muted); font: 500 .975rem/1.4 var(--display); }
.head .clear {
  margin-top: 14px; padding: 8px 14px; font: 600 .9rem var(--display); color: var(--accent-ink);
  background: var(--accent); border: 0; border-radius: 4px; cursor: pointer;
}

/* ---------- notes ---------- */
.note { display: grid; grid-template-columns: 92px minmax(0, 1fr); column-gap: 28px; padding: 30px 0; border-bottom: 1px solid var(--rule); }
.stub { display: flex; flex-direction: column; line-height: 1; padding-top: 4px; }
.stub .d { font: 800 2.5rem/1 var(--display); font-stretch: 125%; letter-spacing: -.02em; }
.stub .m { margin-top: 6px; font: 600 .95rem var(--display); color: var(--muted); }
.stub .y { margin-top: 3px; font: 500 .8rem var(--display); color: var(--muted); }
.note h3 { margin: 0 0 8px; font: 700 1.35rem/1.2 var(--display); font-stretch: 108%; max-width: 40ch; text-wrap: balance; overflow-wrap: anywhere; }
.text { margin: 0; max-width: 64ch; white-space: pre-line; overflow-wrap: anywhere; }
.text.clamp { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 5; line-clamp: 5; overflow: hidden; }
.more {
  margin-top: 8px; padding: 6px 0; background: none; border: 0; cursor: pointer;
  font: 600 .95rem var(--display); color: var(--accent); text-decoration: underline; text-underline-offset: 3px;
}
.text a, .src { color: var(--accent); text-underline-offset: 3px; }
.src { display: inline-flex; align-items: center; gap: 6px; margin-top: 10px; font: 600 .95rem var(--display); overflow-wrap: anywhere; }
.src::after {
  content: ""; width: .8em; height: .8em; background: currentColor; flex: none;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='black' stroke-width='2'%3E%3Cpath d='M6 3H3v10h10v-3M9 2h5v5M14 2 7 9'/%3E%3C/svg%3E") center / contain no-repeat;
          mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='black' stroke-width='2'%3E%3Cpath d='M6 3H3v10h10v-3M9 2h5v5M14 2 7 9'/%3E%3C/svg%3E") center / contain no-repeat;
}
.meta { display: flex; flex-wrap: wrap; gap: 4px 16px; margin-top: 12px; font: 500 .875rem var(--display); color: var(--muted); }
.meta a { color: var(--accent); font-weight: 600; text-underline-offset: 3px; }
.filter { display: flex; flex-wrap: wrap; gap: 0 18px; margin-top: 14px; }
.filter button { padding: 8px 0 7px; background: none; border: 0; border-bottom: 3px solid transparent; cursor: pointer; font: 600 .95rem var(--display); color: var(--muted); }
.filter button[aria-pressed="true"] { color: var(--ink); border-bottom-color: var(--accent); }
.filter .n { margin-left: 6px; font-weight: 500; font-variant-numeric: tabular-nums; }
.done { display: inline-flex; align-items: center; gap: 10px; margin-top: 12px; min-height: 40px; cursor: pointer; font: 600 .95rem var(--display); user-select: none; }
.done input { width: 22px; height: 22px; margin: 0; accent-color: var(--accent); cursor: pointer; }
.note.is-done .stub, .note.is-done .text, .note.is-done .src { opacity: .5; }
.note.is-done h3 { opacity: .55; text-decoration: line-through; text-decoration-thickness: 2px; }
mark { background: var(--mark); color: inherit; padding: 0 .1em; border-radius: 2px; }

.state { margin: 36px 0 0; max-width: 46ch; color: var(--muted); font: 500 1.05rem/1.5 var(--display); }
.state strong { color: var(--ink); font-weight: 700; }

@media (min-width: 1600px) {
  html { font-size: 112.5%; }
  .shell { max-width: 1320px; }
}

/* ---------- mobile et tablette : lecture d'un seul tenant ---------- */
@media (max-width: 859px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .rail { display: contents; }
  .top { flex-direction: row; align-items: center; gap: 14px; padding: 10px 16px; }
  .brand { font-size: 1.1rem; white-space: nowrap; }
  .search { flex: 1; min-width: 0; }
  nav { position: sticky; top: 0; z-index: 5; background: var(--page); border-bottom: 1px solid var(--rule); }
  .track { overflow-x: auto; scrollbar-width: none; padding: 0 16px; -webkit-mask-image: linear-gradient(to right, transparent 0, #000 var(--fl, 0px), #000 calc(100% - var(--fr, 0px)), transparent 100%); mask-image: linear-gradient(to right, transparent 0, #000 var(--fl, 0px), #000 calc(100% - var(--fr, 0px)), transparent 100%); }
  .track::-webkit-scrollbar { display: none; }
  #index { display: flex; border-left: 0; width: max-content; }
  #index a { padding: 10px 14px 12px; white-space: nowrap; gap: 8px; }
  #index li:first-child a { padding-left: 0; }
  .marker { left: 0; top: auto; bottom: 0; height: 3px; width: var(--mw, 0); transform: translateX(var(--mx, 0)); transition: transform .28s cubic-bezier(.3, .7, .2, 1), width .28s cubic-bezier(.3, .7, .2, 1); }
  main { padding: 20px 16px calc(72px + env(safe-area-inset-bottom)); }
  .head { padding-bottom: 14px; border-bottom-width: 2px; }
  .head h1 { font-size: 1.9rem; }
  .head h1.compact { font-size: 1.4rem; }
  .head p { margin-top: 6px; font-size: .9rem; }
  .head .last { display: none; }
  /* le texte s'affiche en entier : plus de « Lire la suite » */
  .text.clamp { display: block; overflow: visible; -webkit-line-clamp: unset; line-clamp: unset; }
  .more { display: none !important; }
}
@media (max-width: 599px) {
  .note { grid-template-columns: minmax(0, 1fr); padding: 18px 0 20px; }
  .stub { flex-direction: row; align-items: baseline; gap: 6px; margin-bottom: 4px; padding: 0; }
  .stub .d { font-size: 1.05rem; }
  .stub .m, .stub .y, .stub .t { margin: 0; font-size: .9rem; }
  .stub .t { display: inline; margin-left: 4px; font: 500 .9rem var(--display); color: var(--muted); }
  .note h3 { font-size: 1.2rem; margin-bottom: 6px; max-width: none; }
  .text { max-width: none; }
  .meta { margin-top: 8px; }
  .meta .time { display: none; }
}
@media (min-width: 600px) and (max-width: 859px) {
  .top { padding-inline: 32px; }
  .search { max-width: 420px; }
  .track { padding-inline: 32px; }
  main { padding: 28px 32px calc(72px + env(safe-area-inset-bottom)); }
  .note { grid-template-columns: 76px minmax(0, 1fr); column-gap: 22px; }
  .stub .d { font-size: 2.1rem; }
}

/* ---------- écrans tactiles : zones à toucher de 44 px minimum ---------- */
@media (pointer: coarse) {
  #index a { min-height: 44px; align-items: center; padding-top: 12px; padding-bottom: 12px; }
  .more, .clear { min-height: 44px; display: inline-flex; align-items: center; }
  .src, .meta a { min-height: 44px; display: inline-flex; align-items: center; }
  .meta { gap: 0 20px; }
  .filter button { min-height: 44px; padding-top: 0; padding-bottom: 0; }
  .done { min-height: 44px; }
}

@media (prefers-reduced-motion: reduce) {
  .marker { transition: none; }
}
