/* ============================================================================
   Carnet de cours - feuille de style notebook
   Direction artistique : carnet manuscrit illustre.
   Une encre signature par chapitre, papier creme texture, post-its.
   ============================================================================ */

@import url("https://fonts.googleapis.com/css2?family=Caveat:wght@400;500;600;700&family=Kalam:wght@300;400;700&family=Lora:ital,wght@0,400;0,500;0,600;0,700;1,400;1,500&family=JetBrains+Mono:wght@400;500;700&display=swap");

:root {
  --ink: oklch(0.22 0.03 270);
  --ink-soft: oklch(0.40 0.03 270);
  --ink-faint: oklch(0.60 0.02 270);
  --paper: oklch(0.97 0.012 85);
  --paper-shade: oklch(0.94 0.018 85);
  --paper-dark: oklch(0.90 0.020 85);
  --signature: oklch(0.38 0.14 245);
  --signature-soft: oklch(0.55 0.12 245);
  --signature-tint: oklch(0.88 0.06 245);
  --signature-wash: oklch(0.93 0.04 245);
  --hl-yellow: oklch(0.93 0.18 95 / 0.55);
  --hl-pink: oklch(0.88 0.13 0 / 0.45);
  --hl-green: oklch(0.92 0.15 145 / 0.50);
  --hl-orange: oklch(0.88 0.15 60 / 0.50);
  --postit-yellow: oklch(0.93 0.13 95);
  --postit-pink: oklch(0.87 0.10 0);
  --postit-blue: oklch(0.88 0.08 235);
  --postit-green: oklch(0.91 0.09 145);
  --shadow-paper: 0 1px 2px rgba(40, 30, 15, 0.08), 0 3px 12px rgba(40, 30, 15, 0.06);
  --shadow-lifted: 0 8px 24px rgba(40, 30, 15, 0.12), 0 2px 4px rgba(40, 30, 15, 0.06);
  --serif: "Lora", Georgia, "Times New Roman", serif;
  --hand: "Caveat", "Kalam", cursive;
  --hand-tight: "Kalam", cursive;
  --mono: "JetBrains Mono", ui-monospace, Menlo, Consolas, monospace;
}

body[data-chapter="cm1"] {
  --signature: oklch(0.36 0.14 245);
  --signature-soft: oklch(0.55 0.13 245);
  --signature-tint: oklch(0.86 0.06 245);
  --signature-wash: oklch(0.93 0.035 245);
}

body[data-chapter="cm2"] {
  --signature: oklch(0.40 0.13 150);
  --signature-soft: oklch(0.55 0.13 150);
  --signature-tint: oklch(0.86 0.07 150);
  --signature-wash: oklch(0.93 0.04 150);
}

body[data-chapter="cm3"] {
  --signature: oklch(0.42 0.17 25);
  --signature-soft: oklch(0.55 0.16 25);
  --signature-tint: oklch(0.87 0.08 25);
  --signature-wash: oklch(0.94 0.04 25);
}

body[data-chapter="cm4"] {
  --signature: oklch(0.40 0.15 315);
  --signature-soft: oklch(0.55 0.14 315);
  --signature-tint: oklch(0.87 0.06 315);
  --signature-wash: oklch(0.94 0.035 315);
}

body[data-chapter="cm5"] {
  --signature: oklch(0.48 0.13 55);
  --signature-soft: oklch(0.60 0.13 55);
  --signature-tint: oklch(0.88 0.07 55);
  --signature-wash: oklch(0.94 0.04 55);
}

body[data-chapter="cm6"] {
  --signature: oklch(0.32 0.05 270);
  --signature-soft: oklch(0.48 0.05 270);
  --signature-tint: oklch(0.86 0.025 270);
  --signature-wash: oklch(0.93 0.012 270);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background: var(--paper);
  background-image:
    radial-gradient(circle at 16% 12%, oklch(0.90 0.05 85 / 0.28), transparent 28rem),
    radial-gradient(circle at 85% 6%, var(--signature-wash), transparent 22rem),
    url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='180' height='180'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0.3  0 0 0 0 0.22  0 0 0 0 0.1  0 0 0 0.05 0'/></filter><rect width='100%25' height='100%25' filter='url(%23n)' opacity='0.4'/></svg>");
  background-size: auto, auto, 180px 180px;
  font-family: var(--serif);
  font-size: 17px;
  line-height: 1.7;
}

::selection {
  background: var(--hl-yellow);
  color: var(--ink);
}

a {
  color: var(--signature);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

a:hover {
  color: var(--signature-soft);
}

/* ============================================================ topbar */

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.7rem clamp(1rem, 3vw, 1.7rem);
  border-bottom: 1px solid var(--signature-tint);
  background: oklch(0.96 0.012 85 / 0.94);
  backdrop-filter: saturate(120%) blur(8px);
}

.topbar .brand {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--signature);
  font-family: var(--hand);
  font-size: 1.5rem;
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
}

.topbar svg {
  width: 24px;
  height: 24px;
  flex: 0 0 auto;
}

.topbar nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.25rem;
}

.topbar nav a {
  padding: 0.4rem 0.7rem;
  border-radius: 5px;
  color: var(--ink-soft);
  font-size: 0.85rem;
  text-decoration: none;
  transition: color 160ms ease-out, background 160ms ease-out;
}

.topbar nav a:hover {
  background: var(--signature-wash);
  color: var(--signature);
}

.topbar nav a.active {
  background: var(--signature);
  color: var(--paper);
  font-weight: 600;
}

/* ============================================================ breadcrumb */

.breadcrumb {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem;
  margin: 0 0 1.4rem;
  color: var(--ink-soft);
  font-family: var(--hand-tight);
  font-size: 0.95rem;
}

.breadcrumb a {
  padding: 0.1rem 0.4rem;
  border-radius: 3px;
  color: var(--ink-soft);
  text-decoration: none;
  transition: background 160ms ease-out, color 160ms ease-out;
}

.breadcrumb a:hover {
  background: var(--signature-wash);
  color: var(--signature);
}

.breadcrumb .sep {
  color: var(--ink-faint);
  font-family: var(--mono);
  font-size: 0.85rem;
}

.breadcrumb .current {
  color: var(--signature);
  font-weight: 700;
}

/* ============================================================ cover page */

.cover {
  max-width: 1120px;
  margin: 0 auto;
  padding: clamp(2.2rem, 6vw, 4rem) 1.5rem 5rem;
}

.cover-kicker {
  margin: 0;
  color: var(--ink-soft);
  font-family: var(--hand);
  font-size: 1.4rem;
}

.cover-title {
  max-width: 12ch;
  margin: 0.1rem 0 0.7rem;
  color: var(--ink);
  font-family: var(--serif);
  font-size: clamp(2.5rem, 7vw, 5rem);
  font-weight: 700;
  letter-spacing: -0.018em;
  line-height: 1.03;
}

.cover-title em,
.chapter-title em {
  color: var(--signature);
  font-style: italic;
  font-weight: 500;
}

.cover-subtitle {
  max-width: 68ch;
  margin: 0 0 2.3rem;
  color: var(--ink-soft);
  font-family: var(--hand);
  font-size: clamp(1.35rem, 2.5vw, 1.75rem);
  line-height: 1.35;
}

.cover-subtitle code {
  font-size: 0.72em;
}

.cover-quick {
  display: flex;
  flex-wrap: wrap;
  gap: 0.8rem;
  margin: 1.5rem 0 2.4rem;
}

.cover-quick a {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.5rem 1.1rem;
  border: 2px solid var(--ink);
  border-radius: 999px;
  background: var(--paper);
  box-shadow: 2px 2px 0 var(--ink);
  color: var(--ink);
  font-family: var(--hand);
  font-size: 1.15rem;
  text-decoration: none;
  transition: transform 160ms ease-out, box-shadow 160ms ease-out;
}

.cover-quick a:hover {
  transform: translate(-1px, -1px);
  box-shadow: 3px 3px 0 var(--ink);
}

.cover-quick svg,
.chapter-meta svg {
  width: 18px;
  height: 18px;
}

.cover-shelf {
  margin: 3rem 0 0;
}

.shelf-title {
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
  margin: 0 0 1.2rem;
  font-family: var(--serif);
  font-size: 1.7rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.shelf-mark {
  color: var(--signature);
  font-family: var(--hand);
  font-size: 1.6rem;
}

.cover-ledger {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  max-width: 760px;
  margin: 0 0 3rem;
  border: 2px solid var(--ink);
  background: oklch(0.98 0.012 85 / 0.82);
  box-shadow: var(--shadow-paper);
}

.cover-ledger div {
  padding: 1rem 1.1rem;
}

.cover-ledger div + div {
  border-left: 1px dashed var(--ink-faint);
}

.cover-ledger strong {
  display: block;
  color: var(--signature);
  font-family: var(--hand);
  font-size: 2rem;
  line-height: 1;
}

.cover-ledger span {
  color: var(--ink-soft);
  font-size: 0.92rem;
}

/* ============================================================ layout grid */

.notebook {
  position: relative;
  display: grid;
  grid-template-columns: 200px minmax(0, 1fr);
  gap: clamp(1.3rem, 4vw, 2.8rem);
  max-width: 1120px;
  margin: 0 auto;
  padding: clamp(1.4rem, 4vw, 2.5rem) 1rem 6rem;
}

.sheet {
  max-width: 1280px;
  margin: 0 auto;
  padding: clamp(1.4rem, 4vw, 2.5rem) 1rem 6rem;
}

.margin-notes {
  position: sticky;
  top: 5.5rem;
  align-self: start;
  max-height: calc(100vh - 7rem);
  min-height: 200px;
  overflow-y: auto;
  padding-right: 1.4rem;
  border-right: 1px dashed var(--ink-faint);
  color: var(--ink-soft);
  font-family: var(--hand);
  font-size: 1.15rem;
  line-height: 1.38;
  text-align: right;
  scrollbar-width: thin;
  scrollbar-color: var(--signature-tint) transparent;
}

.margin-notes::-webkit-scrollbar { width: 4px; }
.margin-notes::-webkit-scrollbar-thumb { background: var(--signature-tint); border-radius: 2px; }

.margin-notes a {
  position: relative;
  display: block;
  padding: 0.2rem 0;
  color: var(--ink-soft);
  text-decoration: none;
  transition: color 150ms ease-out, transform 150ms ease-out;
}

.margin-notes a:hover {
  color: var(--signature);
  transform: translateX(-3px);
}

.margin-notes a.current {
  color: var(--signature);
  font-weight: 700;
}

.margin-notes a.current::after {
  content: "";
  position: absolute;
  top: 50%;
  right: -1.4rem;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--signature);
  transform: translateY(-50%);
}

.margin-notes a.active {
  color: var(--signature);
  font-weight: 700;
}

.margin-notes a.sub {
  font-size: 0.98rem;
  opacity: 0.86;
  padding-right: 0.3rem;
}

.margin-notes .group-label {
  margin: 1.4rem 0 0.3rem;
  color: var(--ink-faint);
  font-family: var(--serif);
  font-size: 0.7rem;
  font-style: italic;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.page {
  min-width: 0;
  padding: 0 1rem;
}

.page--full {
  padding: 0;
}

/* ============================================================ chapter header */

.chapter-header {
  position: relative;
  margin-bottom: 3rem;
  padding-bottom: 2rem;
  border-bottom: 2px solid var(--signature);
}

.chapter-header::after {
  position: absolute;
  right: 30%;
  bottom: -6px;
  left: 0;
  height: 1px;
  background: var(--signature);
  content: "";
  opacity: 0.5;
}

.chapter-eyebrow {
  margin-bottom: 0.2rem;
  color: var(--signature);
  font-family: var(--hand);
  font-size: 1.5rem;
  font-weight: 600;
}

.chapter-title {
  margin: 0 0 0.6rem;
  color: var(--ink);
  font-size: clamp(2rem, 4.5vw, 3.2rem);
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.1;
}

.chapter-subtitle {
  margin: 0;
  color: var(--ink-soft);
  font-size: 1.1rem;
  font-style: italic;
}

.chapter-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 1.5rem;
  margin-top: 1.5rem;
  color: var(--ink-soft);
  font-family: var(--hand-tight);
  font-size: 0.95rem;
}

.chapter-meta span {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

/* ============================================================ sections */

.section,
.course-content section {
  position: relative;
  margin: 3rem 0;
}

h2.section-title,
.course-content h2:not(.section-title) {
  display: flex;
  align-items: baseline;
  gap: 0.7rem;
  margin: 0 0 1.2rem;
  color: var(--ink);
  font-size: 1.7rem;
  font-weight: 600;
}

h2.section-title .num {
  color: var(--signature);
  font-family: var(--hand);
  font-size: 2.2rem;
  font-weight: 700;
  line-height: 0.8;
}

h3.subsection-title,
.course-content h3:not(.subsection-title) {
  position: relative;
  margin: 1.8rem 0 0.6rem;
  padding-left: 1.2rem;
  color: var(--signature);
  font-size: 1.25rem;
  font-style: italic;
  font-weight: 500;
}

h3.subsection-title::before,
.course-content h3:not(.subsection-title)::before {
  position: absolute;
  top: 0.05em;
  left: 0;
  color: var(--signature-soft);
  content: "✦";
  font-size: 0.9em;
}

h4 {
  margin: 1.2rem 0 0.4rem;
  font-size: 1.05rem;
  font-weight: 600;
}

p {
  margin: 0.7rem 0;
}

ul,
ol {
  margin: 0.8rem 0;
  padding-left: 1.4rem;
}

li {
  margin: 0.3rem 0;
}

li::marker {
  color: var(--signature-soft);
}

.sm {
  color: var(--ink-soft);
  font-size: 0.88rem;
}

/* ============================================================ code */

:not(pre) > code {
  padding: 0.1em 0.42em;
  border: 1px solid var(--signature-tint);
  border-radius: 4px;
  background: var(--signature-wash);
  color: var(--signature);
  font-family: var(--mono);
  font-size: 0.88em;
  font-weight: 500;
}

pre {
  position: relative;
  overflow-x: auto;
  margin: 1.2rem 0;
  padding: 1.4rem 1.3rem 1.1rem;
  border: 1px solid oklch(0.32 0.04 270);
  border-radius: 8px;
  background: oklch(0.18 0.025 270);
  box-shadow: var(--shadow-paper);
  color: oklch(0.92 0.01 80);
  font-family: var(--mono);
  font-size: 0.86rem;
  line-height: 1.65;
}

pre::before {
  position: absolute;
  top: -6px;
  left: 1rem;
  width: 72px;
  height: 12px;
  border-radius: 1px;
  background: oklch(0.93 0.01 60 / 0.6);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
  content: "";
}

pre code {
  display: block;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
}

.copy-btn {
  position: absolute;
  top: 0.55rem;
  right: 0.6rem;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.25rem 0.55rem;
  border: 1px solid oklch(0.45 0.04 270);
  border-radius: 4px;
  background: oklch(0.25 0.03 270);
  color: oklch(0.78 0.05 80);
  cursor: pointer;
  font-family: var(--mono);
  font-size: 0.72rem;
  opacity: 0;
  transition: opacity 150ms ease-out, background 150ms ease-out, color 150ms ease-out;
}

pre:hover .copy-btn,
pre:focus-within .copy-btn,
.copy-btn:focus-visible {
  opacity: 1;
}

.copy-btn svg {
  width: 12px;
  height: 12px;
}

.copy-btn:hover {
  background: oklch(0.32 0.03 270);
  color: oklch(0.92 0.01 80);
}

.copy-btn.copied {
  background: oklch(0.40 0.15 145);
  border-color: oklch(0.40 0.15 145);
  color: oklch(0.99 0.005 145);
}

.kw { color: oklch(0.78 0.14 270); font-weight: 600; }
.str { color: oklch(0.82 0.13 90); }
.cmt { color: oklch(0.62 0.04 130); font-style: italic; }
.num { color: oklch(0.78 0.13 30); }
.fn { color: oklch(0.80 0.10 180); }

/* ============================================================ post-its */

.postit {
  position: relative;
  margin: 1.5rem 0;
  padding: 1.1rem 1.3rem;
  border-radius: 1px;
  box-shadow: var(--shadow-paper);
  color: var(--ink);
  font-family: var(--hand);
  font-size: 1.15rem;
  line-height: 1.45;
  transform: rotate(-0.3deg);
}

.postit::before {
  position: absolute;
  top: -6px;
  left: 50%;
  width: 80px;
  height: 12px;
  border-radius: 1px;
  background: oklch(0.93 0.01 60 / 0.6);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
  content: "";
  transform: translateX(-50%);
}

.postit.yellow { background: var(--postit-yellow); }
.postit.pink { background: var(--postit-pink); transform: rotate(0.4deg); }
.postit.blue { background: var(--postit-blue); transform: rotate(-0.5deg); }
.postit.green { background: var(--postit-green); transform: rotate(0.3deg); }

.postit strong {
  font-family: var(--serif);
  font-weight: 700;
}

.postit code {
  border-color: rgba(0,0,0,0.12);
  background: rgba(255,255,255,0.35);
  color: oklch(0.2 0.03 270);
}

/* ============================================================ callouts */

.callout {
  position: relative;
  margin: 1.4rem 0;
  padding: 1rem 1.3rem 1rem 3.2rem;
  border: 1px solid var(--signature-tint);
  border-radius: 8px;
  background: var(--signature-wash);
}

.callout::before {
  position: absolute;
  top: 1rem;
  left: 1rem;
  width: 1.5rem;
  height: 1.5rem;
  background: var(--signature);
  content: "";
  mask: var(--icon) center / contain no-repeat;
  -webkit-mask: var(--icon) center / contain no-repeat;
}

.callout.warn {
  --icon: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path fill='currentColor' d='M12 2 1 21h22L12 2Zm1 16h-2v-2h2v2Zm0-4h-2V8h2v6Z'/></svg>");
  --signature: oklch(0.45 0.17 25);
  border-color: oklch(0.85 0.10 25);
  background: oklch(0.96 0.04 25);
}

.callout.tip {
  --icon: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path fill='currentColor' d='M9 21h6v-2H9v2Zm3-19a7 7 0 0 0-4 12.74V17h8v-2.26A7 7 0 0 0 12 2Z'/></svg>");
}

.callout.key {
  --icon: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path fill='currentColor' d='M7.5 14A4.5 4.5 0 1 1 12 9.5 4.5 4.5 0 0 1 7.5 14Zm0 2A6.5 6.5 0 1 0 1 9.5 6.5 6.5 0 0 0 7.5 16Zm6.2-3.3L22 4.4 19.6 2l-8.3 8.3 2.4 2.4ZM14 14l2 2 2-2-2-2-2 2Z'/></svg>");
  --signature: oklch(0.42 0.15 145);
  border-color: oklch(0.85 0.08 145);
  background: oklch(0.96 0.04 145);
}

.callout.info {
  --icon: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path fill='currentColor' d='M12 2a10 10 0 1 0 10 10A10 10 0 0 0 12 2Zm1 15h-2v-6h2v6Zm0-8h-2V7h2v2Z'/></svg>");
}

.callout strong:first-child {
  display: block;
  margin-bottom: 0.3rem;
  color: var(--signature);
  font-size: 0.9rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* ============================================================ tables */

.tbl-wrap {
  overflow: hidden;
  margin: 1.4rem 0;
  border: 2px solid var(--ink);
  border-radius: 4px;
  background: var(--paper);
  box-shadow: var(--shadow-paper);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}

th,
td {
  padding: 0.7rem 1rem;
  border-bottom: 1px solid var(--signature-tint);
  text-align: left;
}

th {
  border-bottom: 2px solid var(--signature);
  background: var(--signature-wash);
  color: var(--signature);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

tr:last-child td {
  border-bottom: 0;
}

/* ============================================================ cheatsheet */

.cheatsheet {
  position: relative;
  margin: 3rem 0 2rem;
  padding: 1.6rem 1.8rem;
  border: 2px dashed oklch(0.55 0.13 80);
  border-radius: 8px;
  background: linear-gradient(135deg, oklch(0.95 0.05 95) 0%, oklch(0.92 0.06 80) 100%);
}

.cheatsheet::before {
  position: absolute;
  top: -12px;
  left: 1rem;
  padding: 0 0.5rem;
  background: var(--paper);
  color: oklch(0.50 0.12 80);
  content: "couper - plier - recopier";
  font-family: var(--mono);
  font-size: 0.75rem;
  letter-spacing: 0.1em;
}

.cheatsheet h3 {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0 0 0.6rem;
  color: oklch(0.40 0.15 60);
  font-family: var(--hand);
  font-size: 1.6rem;
}

.cheatsheet ul {
  columns: 2;
  column-gap: 2rem;
  padding-left: 1.2rem;
}

.cheatsheet li {
  break-inside: avoid;
}

/* ============================================================ diagrams */

.diagram {
  display: block;
  max-width: 100%;
  margin: 1.8rem auto;
}

.diagram-caption {
  margin: -0.5rem 0 1.5rem;
  color: var(--ink-soft);
  font-family: var(--hand);
  font-size: 1.05rem;
  text-align: center;
}

.sketch-stroke {
  fill: none;
  stroke: var(--ink);
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.5;
}

.sketch-fill {
  fill: var(--signature-wash);
}

.sketch-accent {
  fill: var(--signature);
}

.sketch-label {
  fill: var(--ink);
  font-family: var(--hand);
  font-size: 18px;
}

.sketch-tag {
  fill: var(--ink-soft);
  font-family: var(--serif);
  font-size: 12px;
  font-style: italic;
}

/* ============================================================ tile grid */

.tile-grid,
.chapter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 2.2rem 1.6rem;
  margin-top: 1.4rem;
}

.tile {
  position: relative;
  display: block;
  color: var(--ink);
  text-decoration: none;
}

.tile-body {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  min-height: 180px;
  padding: 1.5rem 1.4rem 1.3rem;
}

.tile h3,
.tile-body h3 {
  margin: 0;
  padding-left: 0;
  color: var(--ink);
  font-family: var(--serif);
  font-size: 1.3rem;
  font-style: normal;
  font-weight: 700;
  line-height: 1.2;
}

.tile h3::before {
  content: none;
}

.tile p,
.tile-body p {
  margin: 0;
  color: var(--ink-soft);
  font-size: 0.95rem;
  line-height: 1.5;
}

.tile .tag {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  color: var(--tile-color, var(--signature));
  font-family: var(--hand);
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.tile .stats {
  display: flex;
  flex-wrap: wrap;
  gap: 0.9rem;
  margin-top: auto;
  padding-top: 0.7rem;
  color: var(--ink-faint);
  font-family: var(--hand);
  font-size: 0.95rem;
}

.tile .stats span {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
}

.tile .stats svg {
  width: 14px;
  height: 14px;
}

.tile-cm1 { --tile-color: oklch(0.40 0.14 245); }
.tile-cm2 { --tile-color: oklch(0.42 0.13 150); }
.tile-cm3 { --tile-color: oklch(0.45 0.17 25); }
.tile-cm4 { --tile-color: oklch(0.42 0.15 315); }
.tile-cm5 { --tile-color: oklch(0.50 0.13 55); }
.tile-cm6 { --tile-color: oklch(0.35 0.05 270); }

/* -------------------------------------------------- FOLDER tile (chemise manila) */

.tile-folder {
  --manila: oklch(0.91 0.040 80);
  --manila-shade: oklch(0.86 0.050 78);
  --manila-edge: oklch(0.52 0.085 75);
  position: relative;
  display: block;
  margin: 20px 4px 6px;
  isolation: isolate;
  text-decoration: none;
  color: var(--ink);
}

/* Feuille blanche qui dépasse par le haut au hover */
.tile-folder .folder-peek {
  position: absolute;
  top: 4px;
  left: 28px;
  right: 28px;
  height: 16px;
  border: 1px solid oklch(0.78 0.02 75);
  border-bottom: none;
  border-radius: 4px 4px 0 0;
  background:
    linear-gradient(180deg, oklch(0.97 0.012 85) 0 60%, oklch(0.93 0.018 75)),
    var(--paper);
  box-shadow: 0 1px 2px rgba(40,30,15,0.06);
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 280ms ease-out, transform 420ms cubic-bezier(0.16, 1, 0.3, 1);
  z-index: 1;
}

/* Onglet trapézoïdal en haut à gauche */
.tile-folder .folder-tab {
  position: absolute;
  top: -16px;
  left: 14px;
  width: 145px;
  height: 24px;
  background:
    linear-gradient(180deg, color-mix(in oklch, var(--manila) 90%, white 10%), var(--manila));
  border: 1.5px solid var(--manila-edge);
  border-bottom: none;
  clip-path: polygon(2px 0, calc(100% - 18px) 0, 100% 100%, 0 100%);
  z-index: 3;
  transform-origin: bottom left;
  transition: transform 380ms cubic-bezier(0.16, 1, 0.3, 1);
}

/* Petite étiquette colorée (encre signature) sur l'onglet */
.tile-folder .folder-tab::after {
  content: "";
  position: absolute;
  top: 6px;
  left: 12px;
  width: 8px;
  height: 12px;
  border-radius: 1.5px;
  background: var(--tile-color, var(--signature));
  box-shadow: 0 1px 0 rgba(0,0,0,0.08);
}

/* Corps du dossier (kraft / manila) */
.tile-folder .folder-body {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  min-height: 200px;
  padding: 1.7rem 1.5rem 1.3rem;
  border: 1.5px solid var(--manila-edge);
  border-radius: 0 8px 8px 8px;
  background:
    /* lignes paper subtiles façon ligné */
    repeating-linear-gradient(0deg, transparent 0 22px, oklch(0.78 0.06 75 / 0.13) 22px 23px),
    /* gradient manila */
    linear-gradient(170deg, color-mix(in oklch, var(--manila) 95%, white 5%), var(--manila-shade) 140%);
  box-shadow:
    inset 0 1px 0 oklch(0.98 0.012 85 / 0.6),
    var(--shadow-paper);
  transition: transform 380ms cubic-bezier(0.16, 1, 0.3, 1), box-shadow 380ms ease-out;
}

/* La tag/h3/description héritent du style commun .tile mais retournent au foreground */
.tile-folder .tile-body { padding: 0; min-height: 0; }  /* legacy reset */

/* HOVER */
.tile-folder:hover .folder-body {
  transform: translateY(-5px);
  box-shadow:
    inset 0 1px 0 oklch(0.98 0.012 85 / 0.6),
    0 14px 28px -10px rgba(40,30,15,0.22),
    0 4px 10px rgba(40,30,15,0.08);
}

.tile-folder:hover .folder-tab {
  transform: translateY(-3px) rotate(-1.5deg);
}

.tile-folder:hover .folder-peek {
  opacity: 1;
  transform: translateY(0);
}

@media (prefers-reduced-motion: reduce) {
  .tile-folder .folder-tab,
  .tile-folder .folder-body,
  .tile-folder .folder-peek {
    transition: none;
  }
}

/* -------------------------------------------------- COURSE tile (feuilles) */

.tile-course {
  position: relative;
  min-height: 220px;
  margin: 4px 8px 8px 4px;
  isolation: isolate;
}

.tile-course .tile-sheet {
  position: absolute;
  inset: 0;
  border: 1.5px solid var(--ink);
  border-radius: 4px;
  background: var(--paper);
  box-shadow: var(--shadow-paper);
  transition: transform 420ms cubic-bezier(0.16, 1, 0.3, 1), box-shadow 350ms ease-out;
}

.tile-course .sheet-3 {
  z-index: 1;
  transform: translate(7px, 7px) rotate(2.2deg);
  background: oklch(0.95 0.015 80);
}

.tile-course .sheet-2 {
  z-index: 2;
  transform: translate(3px, 3px) rotate(0.9deg);
  background: oklch(0.97 0.012 80);
}

.tile-course .sheet-1 {
  z-index: 3;
  background:
    linear-gradient(180deg, var(--tile-color, var(--signature)) 0 5px, transparent 5px),
    var(--paper);
}

.tile-course .tile-body {
  position: relative;
  z-index: 4;
  padding-top: 1.7rem;
}

.tile-course:hover .sheet-3 {
  transform: translate(13px, 11px) rotate(4.5deg);
}

.tile-course:hover .sheet-2 {
  transform: translate(-5px, 7px) rotate(-1.6deg);
}

.tile-course:hover .sheet-1 {
  transform: translate(0, -4px) rotate(-0.3deg);
  box-shadow: var(--shadow-lifted);
}

/* -------------------------------------------------- FILE tile (simple) */

.tile-file {
  display: block;
  min-height: 150px;
  padding: 0;
  border: 1.5px solid var(--ink);
  border-radius: 6px;
  background:
    linear-gradient(135deg, var(--signature-wash), transparent 65%),
    var(--paper);
  box-shadow: var(--shadow-paper);
  color: var(--ink);
  text-decoration: none;
  transition: transform 220ms ease-out, box-shadow 220ms ease-out;
}

.tile-file:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-lifted);
}

.tile-file .tile-body {
  min-height: 150px;
}

.tile-file .tag {
  font-family: var(--mono);
  font-size: 0.75rem;
  letter-spacing: 0.1em;
}

/* -------------------------------------------------- legacy chapter-tile */

.chapter-tile {
  position: relative;
  display: block;
  min-height: 200px;
  padding: 1.4rem 1.6rem;
  border: 1.5px solid var(--ink);
  border-radius: 8px;
  background:
    linear-gradient(180deg, var(--tile-color, var(--signature)) 0 5px, transparent 5px),
    var(--paper);
  box-shadow: var(--shadow-paper);
  color: var(--ink);
  text-decoration: none;
  transition: transform 220ms ease-out, box-shadow 220ms ease-out;
}

.chapter-tile:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lifted);
}

.chapter-tile h3 {
  margin: 0.4rem 0 0.6rem;
  font-family: var(--serif);
  font-size: 1.3rem;
  font-style: normal;
  font-weight: 700;
  padding-left: 0;
}

.chapter-tile h3::before {
  content: none;
}

.chapter-tile .tag {
  color: var(--tile-color, var(--signature));
  font-family: var(--hand);
  font-size: 1.05rem;
  font-weight: 700;
}

.chapter-tile p {
  margin: 0;
  color: var(--ink-soft);
  font-size: 0.95rem;
  line-height: 1.5;
}

.file-tile {
  background:
    linear-gradient(135deg, var(--signature-wash), transparent 55%),
    var(--paper);
}

/* ============================================================ empty state */

.empty-state {
  position: relative;
  max-width: 620px;
  margin: 2rem 0;
  padding: 1.5rem 1.7rem;
  border: 2px dashed var(--signature-tint);
  border-radius: 10px;
  background: oklch(0.98 0.012 85 / 0.75);
}

.empty-state h2 {
  margin: 0 0 0.4rem;
  padding-left: 0;
  color: var(--signature);
  font-family: var(--hand);
  font-size: 1.8rem;
  font-style: normal;
}

.empty-state h2::before {
  content: none;
}

.empty-state p {
  max-width: 60ch;
  margin: 0;
  color: var(--ink-soft);
}

.empty-pin {
  position: absolute;
  top: -7px;
  left: 2rem;
  width: 72px;
  height: 14px;
  border-radius: 1px;
  background: oklch(0.93 0.01 60 / 0.7);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
}

/* ============================================================ utility */

.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
}

.row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1rem;
}

.center {
  text-align: center;
}

.hl-yellow { background: linear-gradient(180deg, transparent 60%, var(--hl-yellow) 60%); padding: 0 2px; }
.hl-pink { background: linear-gradient(180deg, transparent 60%, var(--hl-pink) 60%); padding: 0 2px; }
.hl-green { background: linear-gradient(180deg, transparent 60%, var(--hl-green) 60%); padding: 0 2px; }
.hl-orange { background: linear-gradient(180deg, transparent 60%, var(--hl-orange) 60%); padding: 0 2px; }

/* ============================================================ flashcards */

.flashcards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1.2rem;
  margin: 1.5rem 0;
}

.flashcard {
  height: 200px;
  cursor: pointer;
  perspective: 1200px;
}

.flashcard-inner {
  position: relative;
  width: 100%;
  height: 100%;
  transition: transform 550ms cubic-bezier(0.16, 1, 0.3, 1);
  transform-style: preserve-3d;
}

.flashcard.flipped .flashcard-inner {
  transform: rotateY(180deg);
}

.flashcard-face {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 1.2rem 1.3rem;
  border: 1px solid var(--signature-tint);
  border-radius: 6px;
  box-shadow: var(--shadow-paper);
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}

.flashcard-front {
  padding-top: 2.5rem;
  background:
    linear-gradient(180deg, oklch(0.65 0.20 25 / 0.5) 0, oklch(0.65 0.20 25 / 0.5) 1px, transparent 1px),
    repeating-linear-gradient(180deg, transparent 0 26px, var(--signature-tint) 26px 27px),
    var(--paper);
  background-position: 0 30px, 0 30px, 0 0;
}

.flashcard-back {
  background: var(--signature-wash);
  font-family: var(--mono);
  font-size: 0.85rem;
  transform: rotateY(180deg);
  overflow: auto;
}

.flashcard-face h4 {
  margin: 0 0 0.6rem;
  color: var(--signature);
  font-family: var(--hand);
  font-size: 1.6rem;
  line-height: 1.1;
}

.flashcard-hint {
  position: absolute;
  right: 10px;
  bottom: 6px;
  color: var(--ink-faint);
  font-family: var(--hand);
  font-size: 0.85rem;
}

.flashcard-back pre {
  margin: 0;
  padding: 0.4rem;
  box-shadow: none;
  border: none;
  background: none;
  color: oklch(0.18 0.04 270);
  font-size: 0.8rem;
}

.flashcard-back pre code,
.flashcard-back code {
  background: none;
  border: none;
  color: inherit;
}

/* ============================================================ quiz */

.quiz {
  position: relative;
  margin: 2.5rem 0;
  padding: 1.6rem 1.8rem;
  border: 2px solid var(--ink);
  border-radius: 8px;
  background: var(--paper-shade);
}

.quiz-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 1px dashed var(--ink-faint);
}

.quiz-header h3 {
  margin: 0;
  padding-left: 0;
  color: var(--signature);
  font-family: var(--hand);
  font-size: 1.8rem;
  font-style: normal;
}

.quiz-header h3::before {
  content: none;
}

.quiz-score {
  color: var(--ink-soft);
  font-family: var(--hand);
  font-size: 1.3rem;
  white-space: nowrap;
}

.quiz-score .ok {
  color: oklch(0.50 0.15 145);
  font-weight: 700;
}

.quiz-q {
  margin-bottom: 1.3rem;
  padding-bottom: 1.3rem;
  border-bottom: 1px dotted var(--ink-faint);
}

.quiz-q:last-of-type {
  border-bottom: 0;
}

.quiz-question {
  display: flex;
  gap: 0.6rem;
  margin-bottom: 0.7rem;
  font-weight: 600;
}

.quiz-question .qnum {
  color: var(--signature);
  font-family: var(--hand);
  font-size: 1.4rem;
  font-weight: 700;
  line-height: 1;
}

.quiz-options {
  margin: 0;
  padding: 0;
  list-style: none;
}

.quiz-option {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  margin: 0.2rem 0;
  padding: 0.45rem 0.7rem;
  border-radius: 5px;
  cursor: pointer;
  transition: background 150ms ease-out;
}

.quiz-option:hover:not(.disabled) {
  background: var(--signature-wash);
}

.quiz-option.disabled {
  cursor: default;
}

.quiz-option .box {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  margin-top: 0.05em;
  border: 2px solid var(--ink);
  border-radius: 4px;
  background: var(--paper);
  font-family: var(--hand);
  font-size: 1.2rem;
  font-weight: 700;
}

.quiz-option.correct .box {
  border-color: oklch(0.45 0.16 145);
  background: oklch(0.65 0.16 145);
  color: oklch(0.99 0.005 145);
}

.quiz-option.correct .box::after {
  content: "✓";
}

.quiz-option.wrong .box {
  border-color: oklch(0.45 0.19 25);
  background: oklch(0.65 0.19 25);
  color: oklch(0.99 0.005 25);
}

.quiz-option.wrong .box::after {
  content: "×";
}

.quiz-option.correct .label {
  color: oklch(0.35 0.15 145);
}

.quiz-option.wrong .label {
  color: oklch(0.40 0.18 25);
  text-decoration: line-through;
  text-decoration-thickness: 1px;
}

.quiz-explain {
  display: none;
  margin-top: 0.7rem;
  padding: 0.7rem 1rem;
  border: 1px solid var(--signature-tint);
  border-radius: 4px;
  background: var(--paper);
  color: var(--ink-soft);
  font-size: 0.92rem;
  font-style: italic;
}

.quiz-q.answered .quiz-explain {
  display: block;
}

.quiz-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.8rem;
  margin-top: 1rem;
}

.btn {
  padding: 0.4rem 1.1rem;
  border: 2px solid var(--ink);
  border-radius: 6px;
  background: var(--paper);
  box-shadow: 2px 2px 0 var(--signature);
  color: var(--ink);
  cursor: pointer;
  font-family: var(--hand);
  font-size: 1.15rem;
  transition: transform 150ms ease-out, box-shadow 150ms ease-out;
}

.btn:hover {
  box-shadow: 3px 3px 0 var(--signature);
  transform: translate(-1px, -1px);
}

.btn:active {
  box-shadow: 1px 1px 0 var(--signature);
  transform: translate(1px, 1px);
}

.btn.primary {
  background: var(--signature);
  color: var(--paper);
}

/* ============================================================ Q/R accordion */

.qa-list {
  margin: 1.2rem 0;
}

.qa {
  overflow: hidden;
  margin-bottom: 0.6rem;
  border: 1px solid var(--signature-tint);
  border-radius: 6px;
  background: var(--paper);
  box-shadow: var(--shadow-paper);
}

.qa summary {
  position: relative;
  padding: 0.9rem 3rem 0.9rem 2.6rem;
  color: var(--ink);
  cursor: pointer;
  font-weight: 600;
  list-style: none;
  user-select: none;
}

.qa summary::-webkit-details-marker {
  display: none;
}

.qa summary::before {
  position: absolute;
  top: 50%;
  left: 1rem;
  color: var(--signature);
  content: "?";
  font-family: var(--hand);
  font-size: 1.5rem;
  font-weight: 700;
  line-height: 1;
  transform: translateY(-50%);
}

.qa summary::after {
  position: absolute;
  top: 50%;
  right: 1.2rem;
  color: var(--signature-soft);
  content: "+";
  font-family: var(--hand);
  font-size: 1.5rem;
  transform: translateY(-50%);
}

.qa[open] summary::after {
  content: "−";
}

.qa summary:hover {
  background: var(--signature-wash);
}

.qa-body {
  padding: 0 1.2rem 1.1rem 2.6rem;
  color: var(--ink-soft);
}

.qa-body :first-child {
  margin-top: 0;
}

/* ============================================================ foot nav */

.foot-nav {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 1rem;
  margin-top: 4rem;
  padding-top: 2rem;
  border-top: 1px solid var(--signature-tint);
}

.foot-nav a {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.7rem 1rem;
  border-radius: 8px;
  color: var(--ink);
  font-family: var(--hand);
  font-size: 1.15rem;
  text-decoration: none;
  transition: background 150ms ease-out, color 150ms ease-out, transform 150ms ease-out;
}

.foot-nav a:hover {
  background: var(--signature-wash);
  color: var(--signature);
  transform: translateY(-1px);
}

.foot-nav a span {
  display: flex;
  flex-direction: column;
  gap: 0;
  line-height: 1.1;
}

.foot-nav a span em {
  font-family: var(--serif);
  font-size: 0.7rem;
  font-style: italic;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  opacity: 0.65;
}

.foot-nav a.prev {
  justify-self: start;
  text-align: left;
}

.foot-nav a.next {
  justify-self: end;
  text-align: right;
}

.foot-nav a.next span {
  align-items: flex-end;
}

.foot-nav a.home {
  justify-self: center;
  flex-direction: row;
}

.foot-nav a.disabled {
  pointer-events: none;
  opacity: 0.35;
}

.foot-nav svg {
  width: 18px;
  height: 18px;
}

/* ============================================================ reveal anim */

.reveal {
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 600ms ease-out, transform 600ms ease-out;
}

.reveal.revealed {
  opacity: 1;
  transform: translateY(0);
}

@media (prefers-reduced-motion: reduce) {
  .reveal {
    opacity: 1;
    transform: none;
    transition: none;
  }
}

/* ============================================================ responsive */

@media (max-width: 880px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .topbar nav {
    justify-content: flex-start;
  }

  .notebook {
    grid-template-columns: 1fr;
    padding: 1.5rem 1rem 4rem;
  }

  .margin-notes {
    position: static;
    display: block;
    min-height: 0;
    max-height: none;
    padding: 0 0 1rem;
    border-right: 0;
    border-bottom: 1px dashed var(--ink-faint);
    text-align: left;
  }

  .margin-notes a {
    display: inline-flex;
    margin-right: 0.6rem;
  }

  .margin-notes a.current::after {
    display: none;
  }

  .margin-notes a:hover,
  .margin-notes a.current {
    transform: none;
  }

  .cover-ledger,
  .two-col {
    grid-template-columns: 1fr;
  }

  .cover-ledger div + div {
    border-top: 1px dashed var(--ink-faint);
    border-left: 0;
  }

  .foot-nav {
    grid-template-columns: 1fr;
  }

  .foot-nav a.prev,
  .foot-nav a.next,
  .foot-nav a.home {
    justify-self: stretch;
  }
}

@media (max-width: 700px) {
  body {
    font-size: 16px;
  }

  .cover {
    padding-inline: 1rem;
  }

  .page {
    padding: 0;
  }

  .chapter-grid {
    grid-template-columns: 1fr;
  }

  .cheatsheet ul {
    columns: 1;
  }

  table {
    display: block;
    overflow-x: auto;
    white-space: nowrap;
  }
}

/* ============================================================ print */

@media print {
  .topbar,
  .breadcrumb,
  .margin-notes,
  .foot-nav,
  .flashcards,
  .quiz,
  .qa-list,
  .copy-btn {
    display: none;
  }

  body {
    background: oklch(0.99 0.002 85);
    font-size: 11pt;
  }

  .notebook,
  .sheet {
    display: block;
    max-width: none;
    padding: 0;
  }

  pre,
  .cheatsheet {
    box-shadow: none;
  }

  .reveal {
    opacity: 1;
    transform: none;
  }

  pre {
    page-break-inside: avoid;
  }
}

/* Mode "feuille recto-verso" (A4 paysage, 2 colonnes) */

body[data-layout="sheet"] .topbar nav {
  display: none;
}

body[data-layout="sheet"] .page {
  columns: 2;
  column-gap: 2rem;
}

body[data-layout="sheet"] .section,
body[data-layout="sheet"] .postit,
body[data-layout="sheet"] .callout,
body[data-layout="sheet"] .cheatsheet,
body[data-layout="sheet"] pre,
body[data-layout="sheet"] .tbl-wrap {
  break-inside: avoid;
}

@media print {
  body[data-layout="sheet"] {
    font-size: 9pt;
  }

  body[data-layout="sheet"] .chapter-header {
    column-span: all;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
  }

  body[data-layout="sheet"] .page {
    column-gap: 5mm;
  }

  @page {
    size: A4 landscape;
    margin: 8mm;
  }
}
