:root[data-theme="dark"] {
  --bg: #0b0b0e;
  --bg-2: #16161a;
  --bg-3: #1e1e24;
  --bg-4: #26262e;
  --border: rgba(255, 255, 255, .07);
  --border-2: rgba(255, 255, 255, .13);
  --text: #ececf0;
  --text-2: #8888a0;
  --text-3: #4a4a60;
  --dots: rgba(255, 255, 255, .05);
  --shadow: 0 16px 48px rgba(0, 0, 0, .6);
}

:root[data-theme="light"] {
  --bg: #fbfbfd;
  --bg-2: #ffffff;
  --bg-3: #f3f3f7;
  --bg-4: #e7e7ee;
  --border: rgba(20, 20, 40, .09);
  --border-2: rgba(20, 20, 40, .16);
  --text: #1a1a22;
  --text-2: #63637a;
  --text-3: #9a9ab0;
  --dots: rgba(20, 20, 60, .06);
  --shadow: 0 16px 48px rgba(20, 20, 50, .16);
}

:root {
  --accent: #7c6af7;
  --accent-dim: rgba(124, 106, 247, .14);
  --accent-2: #8b78ff;
  --gold: #f5c518;
  --teal: #2dd4bf;
  --orange: #f99c00;
  --coral: #ff6a67;
  --r: 8px;
  --r-lg: 14px;
  --mono: "Geist Mono", ui-monospace, SFMono-Regular, Consolas, monospace;
  --top: 57px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

* { scrollbar-width: thin; scrollbar-color: var(--bg-4) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--bg-4);
  border-radius: 99px;
  border: 2px solid transparent;
  background-clip: content-box;
}

html { scroll-behavior: smooth; scroll-padding-top: 80px; }

body {
  margin: 0;
  background-color: var(--bg);
  background-image: radial-gradient(var(--dots) 1px, transparent 1px);
  background-size: 22px 22px;
  color: var(--text);
  font-family: Geist, "Segoe UI", system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent-2); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------------------------------------------------------------- barre haute */

header {
  position: fixed;
  inset: 0 0 auto;
  z-index: 30;
  height: var(--top);
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 20px;
  background: var(--bg-2);
  border-bottom: 1px solid var(--border);
}

.brand { display: flex; align-items: center; gap: 9px; color: inherit; }
.brand:hover { text-decoration: none; }
.brand b { font-size: 15px; font-weight: 600; letter-spacing: -.01em; }
.mark { width: 19px; height: 19px; fill: var(--accent); display: block; }

.progress {
  position: fixed;
  top: 0;
  left: 0;
  height: 2px;
  width: 0;
  background: var(--accent);
  z-index: 40;
  transition: width .1s linear;
}

.skip {
  position: absolute;
  left: -9999px;
  top: 8px;
  z-index: 70;
  background: var(--bg-2);
  border: 1px solid var(--accent);
  border-radius: var(--r);
  padding: 8px 14px;
}
.skip:focus { left: 16px; }

.loupe {
  width: 14px;
  height: 14px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
}

.icon {
  background: none;
  border: 1px solid transparent;
  color: var(--text-2);
  font-size: 16px;
  line-height: 1;
  padding: 6px 9px;
  border-radius: var(--r);
  cursor: pointer;
}
.icon:hover { color: var(--text); background: var(--bg-3); }
.burger { display: none; }

.search-open {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: var(--r);
  color: var(--text-3);
  font: inherit;
  font-size: 13px;
  padding: 6px 10px;
  min-width: 210px;
  cursor: pointer;
}
.search-open:hover { border-color: var(--accent); color: var(--text-2); }
.search-open span { margin-right: auto; }

kbd {
  font-family: var(--mono);
  font-size: 10.5px;
  background: var(--bg-4);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 5px;
  color: var(--text-2);
}

/* ---------------------------------------------------------------- structure */

.shell {
  display: grid;
  grid-template-columns: 262px minmax(0, 1fr) 216px;
  gap: 44px;
  max-width: 1480px;
  margin: 0 auto;
  padding: calc(var(--top) + 34px) 30px 80px;
}

.sidebar, .outline {
  position: sticky;
  top: calc(var(--top) + 26px);
  align-self: start;
  max-height: calc(100vh - var(--top) - 50px);
  overflow-y: auto;
  font-size: 13.5px;
}

.project { padding: 0 10px 16px; border-bottom: 1px solid var(--border); margin-bottom: 14px; }
.project b { display: block; font-size: 14.5px; }
.project span { display: block; color: var(--text-3); font-size: 12px; line-height: 1.5; }

.switcher {
  width: 100%;
  font: inherit;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text);
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 8px 10px;
  margin-bottom: 16px;
  outline: none;
}
.switcher:focus { border-color: var(--accent); }

.pages { display: flex; flex-direction: column; gap: 1px; }
.page-link {
  display: block;
  color: var(--text-2);
  padding: 7px 11px;
  border-radius: var(--r);
  border-left: 2px solid transparent;
}
.page-link:hover { color: var(--text); background: var(--bg-3); text-decoration: none; }
.page-link.on {
  color: var(--accent-2);
  background: var(--accent-dim);
  border-left-color: var(--accent);
  font-weight: 500;
}

.outline strong {
  display: block;
  font-size: 11px;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--text-3);
  margin-bottom: 10px;
}
.outline a { display: block; color: var(--text-2); padding: 3px 0; }
.outline a:hover { color: var(--text); text-decoration: none; }
.outline a.on { color: var(--accent-2); }
.outline a.lvl3 { padding-left: 14px; font-size: 12.5px; }

/* ---------------------------------------------------------------- contenu */

main { min-width: 0; }

.crumb { font-size: 12.5px; color: var(--text-3); margin-bottom: 18px; }
.crumb .sep { margin: 0 7px; }

article h1 {
  font-size: 31px;
  line-height: 1.22;
  margin: 0 0 10px;
  letter-spacing: -.025em;
}
article .lead { color: var(--text-2); font-size: 16px; margin: 0 0 32px; }
article > p:first-of-type { color: var(--text-2); }

article h2 {
  font-size: 21px;
  margin: 46px 0 14px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
  letter-spacing: -.015em;
}
article h3 { font-size: 16px; margin: 30px 0 8px; }
article h4 { font-size: 14px; margin: 22px 0 6px; color: var(--text-2); }

.anchor {
  margin-left: 9px;
  color: var(--text-3);
  opacity: 0;
  font-weight: 400;
  font-size: .8em;
}
h2:hover .anchor, h3:hover .anchor { opacity: 1; }

article p { margin: 0 0 14px; }
article ul, article ol { margin: 0 0 16px; padding-left: 22px; }
article li { margin-bottom: 6px; }
article li::marker { color: var(--accent); }
article hr { border: none; border-top: 1px solid var(--border); margin: 34px 0; }
article img { max-width: 100%; border-radius: var(--r); }

code {
  font-family: var(--mono);
  font-size: .87em;
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 1px 6px;
  white-space: nowrap;
}

.code {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--r);
  margin: 0 0 16px;
  overflow: hidden;
}
.code-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 8px 6px 13px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-3);
}
.code-head span {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-3);
  letter-spacing: .04em;
}
.copy {
  font: inherit;
  font-size: 11.5px;
  background: none;
  border: 1px solid var(--border);
  color: var(--text-2);
  border-radius: 5px;
  padding: 2px 9px;
  cursor: pointer;
}
.copy:hover { color: var(--text); border-color: var(--border-2); background: var(--bg-4); }
.code pre { margin: 0; padding: 13px 15px; overflow-x: auto; }
.code code {
  background: none;
  border: none;
  padding: 0;
  font-size: 12.8px;
  line-height: 1.65;
  white-space: pre;
}

.table-wrap { overflow-x: auto; margin: 0 0 20px; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th {
  text-align: left;
  padding: 9px 12px;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--text-3);
  border-bottom: 1px solid var(--border-2);
  white-space: nowrap;
}
td { padding: 9px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }

.method {
  font-family: var(--mono);
  font-size: 10.5px;
  padding: 2px 7px;
  border-radius: 4px;
  background: var(--bg-4);
  color: var(--text-2);
}
.method.get { background: rgba(45, 212, 191, .16); color: #14b8a6; }
.method.post { background: rgba(124, 106, 247, .18); color: var(--accent); }
.method.put { background: rgba(249, 156, 0, .16); color: #d97706; }
.method.del { background: rgba(255, 106, 103, .16); color: #ef4444; }
:root[data-theme="dark"] .method.get { color: var(--teal); }
:root[data-theme="dark"] .method.put { color: var(--orange); }
:root[data-theme="dark"] .method.del { color: var(--coral); }

.callout {
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  background: var(--accent-dim);
  border-radius: 0 var(--r) var(--r) 0;
  padding: 12px 16px;
  margin: 0 0 18px;
}
.callout b {
  display: block;
  font-size: 11px;
  letter-spacing: .07em;
  text-transform: uppercase;
  margin-bottom: 3px;
  color: var(--accent);
}
.callout p { margin: 0; }
.callout.tip { border-left-color: var(--teal); background: rgba(45, 212, 191, .09); }
.callout.tip b { color: #14b8a6; }
.callout.warn { border-left-color: var(--gold); background: rgba(245, 197, 24, .09); }
.callout.warn b { color: #b58900; }
.callout.danger { border-left-color: var(--coral); background: rgba(255, 106, 103, .09); }
.callout.danger b { color: #ef4444; }
:root[data-theme="dark"] .callout.tip b { color: var(--teal); }
:root[data-theme="dark"] .callout.warn b { color: var(--gold); }
:root[data-theme="dark"] .callout.danger b { color: var(--coral); }

/* ---------------------------------------------------------------- accueil */

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(270px, 1fr));
  gap: 14px;
}
.doc-card {
  display: block;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 20px;
  color: inherit;
  transition: border-color .15s, transform .15s;
}
.doc-card:hover { border-color: var(--accent); text-decoration: none; transform: translateY(-2px); }
.doc-card h2 { font-size: 16px; margin: 0 0 6px; border: none; padding: 0; }
.doc-card p { color: var(--text-2); font-size: 13px; margin: 0 0 12px; }
.tag {
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--accent);
  background: var(--accent-dim);
  padding: 3px 9px;
  border-radius: 99px;
}

/* ---------------------------------------------------------------- pied */

.pager {
  display: flex;
  gap: 14px;
  justify-content: space-between;
  margin-top: 54px;
}
.pager-link {
  flex: 1;
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 13px 17px;
  color: inherit;
  background: var(--bg-2);
  max-width: 300px;
}
.pager-link:hover { border-color: var(--accent); text-decoration: none; }
.pager-link span { display: block; font-size: 11.5px; color: var(--text-3); }
.pager-link b { font-weight: 500; }
.pager-link.next { text-align: right; margin-left: auto; }

footer {
  margin-top: 50px;
  padding-top: 22px;
  border-top: 1px solid var(--border);
  color: var(--text-3);
  font-size: 12.5px;
}

/* ---------------------------------------------------------------- recherche */

.palette {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(0, 0, 0, .55);
  display: flex;
  justify-content: center;
  padding: 90px 20px 20px;
}
.palette-box {
  width: 100%;
  max-width: 620px;
  background: var(--bg-2);
  border: 1px solid var(--border-2);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow);
  overflow: hidden;
  height: fit-content;
}
#palette-input {
  width: 100%;
  font: inherit;
  font-size: 15px;
  padding: 15px 18px;
  background: none;
  border: none;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  outline: none;
}
.palette-results { max-height: 380px; overflow-y: auto; }
.palette-empty { color: var(--text-3); font-size: 13px; padding: 16px 18px; margin: 0; }

.palette-row {
  display: block;
  padding: 10px 18px;
  border-bottom: 1px solid var(--border);
  color: inherit;
}
.palette-row:hover, .palette-row.on { background: var(--accent-dim); text-decoration: none; }
.palette-row b { display: block; font-size: 13.5px; font-weight: 500; }
.palette-row span {
  display: block;
  font-size: 12px;
  color: var(--text-2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.palette-row i {
  font-style: normal;
  font-size: 10.5px;
  font-family: var(--mono);
  color: var(--text-3);
}

.palette-foot {
  display: flex;
  gap: 16px;
  padding: 9px 18px;
  border-top: 1px solid var(--border);
  background: var(--bg-3);
  font-size: 11.5px;
  color: var(--text-3);
}

mark {
  background: rgba(124, 106, 247, .28);
  color: inherit;
  border-radius: 3px;
  padding: 0 1px;
}

/* Coloration du code */
.code i { font-style: normal; }
.tok-cmd { color: var(--accent-2); }
.tok-flag { color: var(--teal); }
.tok-str { color: #86c06c; }
.tok-key { color: var(--accent-2); }
.tok-num { color: var(--orange); }
.tok-atom { color: var(--coral); }
.tok-note { color: var(--text-3); }
:root[data-theme="light"] .tok-str { color: #3f7f2f; }
:root[data-theme="light"] .tok-flag { color: #0f766e; }
:root[data-theme="light"] .tok-num { color: #b45309; }
:root[data-theme="light"] .tok-atom { color: #dc2626; }

/* ---------------------------------------------------------------- impression */

@media print {
  header, .sidebar, .outline, .pager, .palette, .progress, .anchor, .copy, .skip { display: none !important; }
  body { background: #fff; color: #000; font-size: 11pt; }
  .shell { display: block; max-width: none; padding: 0; }
  .code, table, .callout { break-inside: avoid; }
  a { color: #000; text-decoration: underline; }
}

/* ---------------------------------------------------------------- mobile */

@media (max-width: 1200px) {
  .shell { grid-template-columns: 244px minmax(0, 1fr); gap: 34px; }
  .outline { display: none; }
}

@media (max-width: 860px) {
  .shell { grid-template-columns: minmax(0, 1fr); padding: calc(var(--top) + 24px) 18px 60px; }
  .burger { display: block; }
  .search-open { min-width: 0; }
  .search-open span, .palette-foot { display: none; }

  .sidebar {
    position: fixed;
    inset: var(--top) auto 0 0;
    width: 268px;
    max-height: none;
    background: var(--bg-2);
    border-right: 1px solid var(--border);
    padding: 20px;
    transform: translateX(-100%);
    transition: transform .2s;
    z-index: 25;
  }
  .sidebar.open { transform: none; }
  article h1 { font-size: 26px; }
  .pager { flex-direction: column; }
  .pager-link { max-width: none; }
}
