/* ————————————————————————————————————————————————
   Maïeutique — design system
   Minimal, éditorial, monochrome + un seul accent.
   ———————————————————————————————————————————————— */

:root {
  --paper:      #fcfbf9;
  --paper-2:    #f4f2ee;
  --paper-3:    #ebe8e2;
  --ink:        #17171a;
  --ink-2:      #55555c;
  --ink-3:      #8b8b93;
  --line:       #e3e0da;
  --line-2:     #d3cfc7;
  --accent:     #2f5468;
  --accent-soft:#e8eef1;
  --ok:         #3d7a5a;
  --ok-soft:    #e6f0ea;
  --warn:       #9a6b26;
  --warn-soft:  #f6eedf;

  --r-s: 6px;
  --r-m: 10px;
  --r-l: 16px;

  --sans: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Helvetica, Arial, sans-serif;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Times New Roman", Georgia, serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace;

  --shadow: 0 1px 2px rgba(20,20,25,.04), 0 8px 24px -12px rgba(20,20,25,.10);
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper:      #131316;
    --paper-2:    #1a1a1e;
    --paper-3:    #232328;
    --ink:        #eceae4;
    --ink-2:      #a6a49e;
    --ink-3:      #76747030;
    --ink-3:      #7a7873;
    --line:       #2a2a30;
    --line-2:     #35353c;
    --accent:     #8ab6cd;
    --accent-soft:#1c262c;
    --ok:         #7fbf9c;
    --ok-soft:    #17231d;
    --warn:       #d5a866;
    --warn-soft:  #241d12;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px -12px rgba(0,0,0,.6);
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
a { color: inherit; text-decoration: none; }
button, input, textarea, select { font: inherit; color: inherit; }

/* ——— Layout ——— */
.app { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
/* Écran de connexion : la barre latérale n'a pas lieu d'être. */
.app.sans-nav { grid-template-columns: 1fr; }
.app.sans-nav .sidebar { display: none; }

.sidebar {
  border-right: 1px solid var(--line);
  padding: 26px 18px;
  display: flex; flex-direction: column; gap: 28px;
  position: sticky; top: 0; height: 100vh;
  background: var(--paper);
}
.brand { display: flex; align-items: baseline; gap: 9px; }
.brand-mark { color: var(--accent); font-size: 15px; }
.brand-name { font-family: var(--serif); font-size: 19px; letter-spacing: .2px; }

.nav { display: flex; flex-direction: column; gap: 1px; }
.nav a {
  display: flex; align-items: center; gap: 11px;
  padding: 8px 10px; border-radius: var(--r-s);
  color: var(--ink-2); font-size: 14px;
  transition: background .14s ease, color .14s ease;
}
.nav a:hover { background: var(--paper-2); color: var(--ink); }
.nav a.active { background: var(--paper-2); color: var(--ink); font-weight: 500; }
.nav a.active .nav-i { border-color: var(--accent); color: var(--accent); }
.nav-i {
  width: 19px; height: 19px; flex: none;
  display: grid; place-items: center;
  border: 1px solid var(--line-2); border-radius: 50%;
  font-size: 10px; color: var(--ink-3);
  font-variant-numeric: tabular-nums;
}
.sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: 14px; }
.nav-minor { font-size: 13px; color: var(--ink-3); }
.nav-minor:hover { color: var(--ink); }

.main { min-width: 0; }
.page { max-width: 780px; margin: 0 auto; padding: 64px 40px 120px; }
.page-wide { max-width: 1000px; }

/* ——— Typographie ——— */
h1, h2, h3 { font-family: var(--serif); font-weight: 400; letter-spacing: -.01em; }
h1 { font-size: 34px; line-height: 1.2; margin: 0 0 10px; }
h2 { font-size: 22px; margin: 0 0 8px; }
h3 { font-size: 17px; margin: 0 0 6px; }
p { margin: 0 0 14px; }
.lede { color: var(--ink-2); font-size: 16px; max-width: 60ch; }
.eyebrow {
  font-size: 11px; letter-spacing: .13em; text-transform: uppercase;
  color: var(--ink-3); margin-bottom: 14px; font-weight: 500;
}
.muted { color: var(--ink-2); }
.small { font-size: 13px; }
.mono { font-family: var(--mono); font-size: 12.5px; }
hr.rule { border: 0; border-top: 1px solid var(--line); margin: 34px 0; }

/* ——— Contrôles ——— */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 9px 16px; border-radius: var(--r-s);
  border: 1px solid var(--line-2); background: var(--paper);
  cursor: pointer; font-size: 14px;
  transition: background .14s, border-color .14s, transform .06s;
}
.btn:hover { background: var(--paper-2); }
.btn:active { transform: translateY(.5px); }
.btn[disabled] { opacity: .45; cursor: not-allowed; }
.btn-primary { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.btn-primary:hover { background: var(--ink); opacity: .88; }
.btn-ghost { border-color: transparent; background: transparent; color: var(--ink-2); }
.btn-ghost:hover { background: var(--paper-2); color: var(--ink); }
.btn-sm { padding: 5px 11px; font-size: 13px; }

.field { display: flex; flex-direction: column; gap: 7px; margin-bottom: 18px; }
.field label { font-size: 13px; color: var(--ink-2); }
.input, textarea.input {
  width: 100%; padding: 11px 13px;
  background: var(--paper); border: 1px solid var(--line-2);
  border-radius: var(--r-s); outline: none;
  transition: border-color .14s, box-shadow .14s;
}
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
textarea.input { resize: vertical; line-height: 1.6; }
select.input { appearance: none; background-image: none; }

.ask {
  display: flex; gap: 10px; align-items: flex-end;
  border: 1px solid var(--line-2); border-radius: var(--r-m);
  padding: 10px 10px 10px 14px; background: var(--paper);
  transition: border-color .14s, box-shadow .14s;
}
.ask:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.ask textarea {
  flex: 1; border: 0; outline: 0; background: transparent;
  resize: none; padding: 4px 0; max-height: 40vh; line-height: 1.6;
}

/* ——— Cartes ——— */
.card {
  border: 1px solid var(--line); border-radius: var(--r-m);
  padding: 18px 20px; background: var(--paper);
}
.card + .card { margin-top: 10px; }
.card-hover { transition: border-color .14s, box-shadow .14s, transform .1s; cursor: pointer; }
.card-hover:hover { border-color: var(--line-2); box-shadow: var(--shadow); }

.domain-row { display: flex; gap: 14px; align-items: flex-start; padding: 15px 0; border-bottom: 1px solid var(--line); }
.domain-row:last-child { border-bottom: 0; }
.domain-q { color: var(--ink-2); font-size: 14px; font-style: italic; }
.idx {
  flex: none; width: 24px; height: 24px; margin-top: 2px;
  display: grid; place-items: center; border-radius: 50%;
  background: var(--paper-2); color: var(--ink-3);
  font-size: 11px; font-variant-numeric: tabular-nums;
}

/* ——— Chips / statuts ——— */
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 2px 9px; border-radius: 999px; font-size: 11.5px;
  border: 1px solid var(--line-2); color: var(--ink-2); background: var(--paper);
  white-space: nowrap;
}
.chip-ok { color: var(--ok); border-color: transparent; background: var(--ok-soft); }
.chip-wip { color: var(--warn); border-color: transparent; background: var(--warn-soft); }
.dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex: none; }

/* ——— Arbre du programme ——— */
.tree-domain { border: 1px solid var(--line); border-radius: var(--r-m); margin-bottom: 12px; overflow: hidden; }
.tree-domain > summary {
  list-style: none; cursor: pointer; padding: 16px 20px;
  display: flex; align-items: center; gap: 12px;
}
.tree-domain > summary::-webkit-details-marker { display: none; }
.tree-domain > summary:hover { background: var(--paper-2); }
.tree-domain[open] > summary { border-bottom: 1px solid var(--line); }
.tree-title { font-family: var(--serif); font-size: 18px; flex: 1; }
.caret { color: var(--ink-3); transition: transform .16s; font-size: 11px; }
.tree-domain[open] .caret { transform: rotate(90deg); }

.notion { padding: 14px 20px 14px 24px; border-bottom: 1px solid var(--line); }
.notion:last-child { border-bottom: 0; }
.notion-head { display: flex; align-items: baseline; gap: 10px; margin-bottom: 4px; }
.notion-name { font-weight: 500; }
.notion-sum { color: var(--ink-2); font-size: 13.5px; margin-bottom: 10px; }

.chapters { display: flex; flex-direction: column; gap: 2px; }
.chapter {
  display: flex; align-items: center; gap: 12px;
  padding: 9px 12px; border-radius: var(--r-s);
  cursor: pointer; transition: background .12s;
  border: 1px solid transparent;
}
.chapter:hover { background: var(--paper-2); border-color: var(--line); }
.chapter-title { flex: 1; font-size: 14px; }
.chapter-obj { color: var(--ink-3); font-size: 12.5px; }
.mark {
  width: 17px; height: 17px; flex: none; border-radius: 50%;
  border: 1.5px solid var(--line-2);
  display: grid; place-items: center; font-size: 10px; color: transparent;
}
.mark-ok { border-color: var(--ok); background: var(--ok); color: #fff; }
.mark-wip { border-color: var(--warn); border-style: dashed; }

/* ——— Barres de progression ——— */
.bar { height: 3px; background: var(--paper-3); border-radius: 3px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--accent); border-radius: 3px; transition: width .4s ease; }
.bar-ok > i { background: var(--ok); }
.stat { display: flex; align-items: baseline; gap: 8px; }
.stat-n { font-family: var(--serif); font-size: 28px; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin: 22px 0 30px; }

/* ——— Chat ——— */
.chat-layout { display: grid; grid-template-columns: 1fr 300px; height: 100vh; overflow: hidden; }
/* min-height:0 : sans ça, le flux de messages pousse le conteneur et fait défiler la page entière. */
.chat-main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.chat-scroll { min-height: 0; }
.chat-head {
  padding: 18px 32px; border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 14px; background: var(--paper);
}
.chat-head .back { color: var(--ink-3); font-size: 18px; line-height: 1; }
.chat-head .back:hover { color: var(--ink); }
.chat-scroll { flex: 1; overflow-y: auto; padding: 34px 32px 20px; }
.chat-inner { max-width: 660px; margin: 0 auto; }
.chat-foot { border-top: 1px solid var(--line); padding: 14px 32px 20px; background: var(--paper); }
.chat-foot .ask { max-width: 660px; margin: 0 auto; }

.msg { margin-bottom: 26px; }
.msg-role {
  font-size: 11px; letter-spacing: .1em; text-transform: uppercase;
  color: var(--ink-3); margin-bottom: 7px;
}
.msg-body p { margin: 0 0 12px; }
.msg-body p:last-child { margin-bottom: 0; }
.msg-body ul, .msg-body ol { margin: 0 0 12px; padding-left: 20px; }
.msg-body li { margin-bottom: 4px; }
.msg-body code { font-family: var(--mono); font-size: 12.5px; background: var(--paper-2); padding: 1px 5px; border-radius: 4px; }
.msg-body em { font-style: italic; }
.msg-user .msg-body {
  background: var(--paper-2); border-radius: var(--r-m);
  padding: 12px 16px; white-space: pre-wrap;
}
.msg-tutor .msg-body { font-size: 15.5px; }

.eval-flash {
  display: flex; gap: 9px; align-items: flex-start;
  border-left: 2px solid var(--ok); padding: 3px 0 3px 12px;
  margin: -12px 0 22px; font-size: 13px; color: var(--ink-2);
}
.eval-flash.partial { border-left-color: var(--warn); }

/* ——— Introduction du chapitre ——— */
.intro {
  border: 1px solid var(--line); border-radius: var(--r-m);
  background: var(--paper-2); margin-bottom: 30px; overflow: hidden;
}
.intro > summary {
  list-style: none; cursor: pointer; padding: 14px 20px;
  display: flex; align-items: center; gap: 10px;
}
.intro > summary::-webkit-details-marker { display: none; }
.intro > summary:hover { background: var(--paper-3); }
.intro[open] > summary { border-bottom: 1px solid var(--line); }
.intro[open] .caret { transform: rotate(90deg); }
.intro-body { padding: 20px 22px 22px; }
.intro-expose { font-size: 15.5px; }
.intro-expose p:first-child { margin-top: 0; }
.intro-exemple, .intro-piege, .intro-retenir {
  margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line);
}
.intro-exemple-txt, .intro-piege-txt { font-size: 14.5px; }
.intro-piege-txt { color: var(--warn); }
.intro-retenir ul { margin: 0; padding-left: 18px; font-size: 14.5px; }
.intro-retenir li { margin-bottom: 5px; }

.passer-au-test {
  display: flex; align-items: center; justify-content: space-between;
  gap: 18px; flex-wrap: wrap;
  border-top: 1px solid var(--line); padding-top: 20px; margin-bottom: 26px;
}

.aside-panel {
  border-left: 1px solid var(--line); padding: 22px 20px;
  overflow-y: auto; background: var(--paper);
}
.crit { padding: 11px 0; border-bottom: 1px solid var(--line); display: flex; gap: 10px; }
.crit:last-child { border-bottom: 0; }
.crit-txt { font-size: 13px; line-height: 1.5; }
.crit-just { font-size: 12px; color: var(--ink-3); margin-top: 4px; font-style: italic; }
.crit-non .crit-txt { color: var(--ink-3); }

.banner-ok {
  border: 1px solid var(--ok); background: var(--ok-soft);
  border-radius: var(--r-m); padding: 18px 20px; margin-bottom: 26px;
}
.banner-ok h3 { color: var(--ok); margin-bottom: 4px; }

/* ——— Divers ——— */
.typing { display: inline-flex; gap: 4px; align-items: center; height: 20px; }
.typing i { width: 5px; height: 5px; border-radius: 50%; background: var(--ink-3); animation: blink 1.2s infinite; }
.typing i:nth-child(2) { animation-delay: .18s; }
.typing i:nth-child(3) { animation-delay: .36s; }
@keyframes blink { 0%,60%,100% { opacity: .22 } 30% { opacity: .95 } }

.spinner {
  width: 14px; height: 14px; border-radius: 50%;
  border: 1.5px solid var(--line-2); border-top-color: var(--accent);
  animation: spin .7s linear infinite; display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg) } }

.toasts { position: fixed; bottom: 22px; right: 22px; display: flex; flex-direction: column; gap: 8px; z-index: 50; }
.toast {
  background: var(--ink); color: var(--paper); padding: 10px 15px;
  border-radius: var(--r-s); font-size: 13.5px; max-width: 420px;
  box-shadow: var(--shadow); animation: rise .2s ease;
}
.toast.err { background: #8b2f2f; }
@keyframes rise { from { opacity: 0; transform: translateY(6px) } }

.empty { border: 1px dashed var(--line-2); border-radius: var(--r-m); padding: 40px; text-align: center; color: var(--ink-2); }

.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.between { display: flex; justify-content: space-between; align-items: center; gap: 16px; }
.gap-l { gap: 22px; }
.mt-l { margin-top: 30px; }
.mb-l { margin-bottom: 30px; }

pre.json {
  font-family: var(--mono); font-size: 12px; line-height: 1.6;
  background: var(--paper-2); border: 1px solid var(--line);
  border-radius: var(--r-m); padding: 16px; overflow: auto; max-height: 460px;
}

.check { display: flex; gap: 10px; align-items: flex-start; padding: 11px 13px; border: 1px solid var(--line); border-radius: var(--r-s); cursor: pointer; }
.check input { margin-top: 4px; accent-color: var(--accent); }
.check:hover { background: var(--paper-2); }

.progress-mini { font-size: 12px; color: var(--ink-3); display: flex; flex-direction: column; gap: 7px; }

@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: row; align-items: center; gap: 16px; padding: 12px 16px; overflow-x: auto; }
  .nav { flex-direction: row; }
  .sidebar-foot { margin: 0; }
  #sidebar-progress { display: none; }
  .page { padding: 32px 20px 90px; }
  .chat-layout { grid-template-columns: 1fr; height: auto; overflow: visible; }
  .chat-scroll { overflow: visible; }
  .aside-panel { border-left: 0; border-top: 1px solid var(--line); }
  .chat-scroll, .chat-foot, .chat-head { padding-left: 18px; padding-right: 18px; }
}
