/* Story Cash — style « encré » : papier chaud, trait noir, couleurs du jour à la nuit. */
:root {
  --paper: #f5efe3;
  --card: #fffdf8;
  --ink: #161412;
  --fg: #161412;
  --mut: #6d665c;
  --line: #161412;
  --soft: #ece4d4;
  --shadow: 4px 4px 0 var(--ink);
  --shadow-sm: 2px 2px 0 var(--ink);
  --ok: #1f9d61;
  --gold: #f2b134;
  --sunset: #f0643a;
  --violet: #7a4bd1;
  --night: #1f2f6e;
  --head: "Bricolage Grotesque", Inter, system-ui, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #14161f; --card: #1c1f2b; --ink: #f1ead9; --fg: #f1ead9; --mut: #a39d90;
    --line: #3a3f52; --soft: #262a38; --shadow: 4px 4px 0 #000; --shadow-sm: 2px 2px 0 #000;
  }
}
:root[data-theme="dark"] {
  --paper: #14161f; --card: #1c1f2b; --ink: #f1ead9; --fg: #f1ead9; --mut: #a39d90;
  --line: #3a3f52; --soft: #262a38; --shadow: 4px 4px 0 #000; --shadow-sm: 2px 2px 0 #000;
}

* { box-sizing: border-box }
html, body { margin: 0 }
body { font: 16px/1.65 Inter, system-ui, -apple-system, Segoe UI, sans-serif; background: var(--paper); color: var(--fg); -webkit-font-smoothing: antialiased }
a { color: inherit; text-decoration: none }
button { font: inherit; color: inherit; cursor: pointer }
.hidden { display: none !important }
h1, h2, h3 { font-family: var(--head); letter-spacing: -.02em; line-height: 1.1 }

/* Logo */
.logo { display: flex; align-items: center; gap: 10px; font-family: var(--head); font-weight: 800; font-size: 19px }
.logo-mark { width: 32px; height: 32px; border-radius: 9px; background: var(--gold); color: #161412; border: 2px solid var(--line); display: grid; place-items: center; font-size: 16px; box-shadow: var(--shadow-sm) }

/* Boutons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 2px solid var(--line); background: var(--card); padding: 10px 18px; border-radius: 12px; font-weight: 600; font-size: 15px; box-shadow: var(--shadow-sm); transition: transform .08s, box-shadow .08s; white-space: nowrap }
.btn:hover { transform: translate(-1px, -1px); box-shadow: 3px 3px 0 var(--ink) }
.btn:active { transform: translate(2px, 2px); box-shadow: none }
.btn-ink { background: var(--ink); color: var(--paper); border-color: var(--ink) }
.btn-ok { background: var(--ok); color: #fff }
.btn-block { width: 100% }
.btn-lg { padding: 14px 22px; font-size: 16px; border-radius: 14px }

/* Connexion */
.login { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr }
.login-art { position: relative; overflow: hidden; border-right: 2px solid var(--line); display: flex; align-items: flex-end; padding: 48px }
.sky { position: absolute; inset: 0; background: linear-gradient(180deg, #1f2f6e 0%, #7a4bd1 38%, #f0643a 70%, #f2b134 100%) }
.sun { position: absolute; width: 220px; height: 220px; border-radius: 50%; background: #ffd77a; border: 3px solid #161412; left: 50%; top: 22%; transform: translateX(-50%); box-shadow: 0 0 0 18px rgba(255, 215, 122, .25) }
.login-quote { position: relative; color: #fff; font-family: var(--head); font-weight: 800; font-size: 30px; line-height: 1.15; margin: 0; max-width: 460px; text-shadow: 2px 2px 0 #161412 }
.login-card { align-self: center; justify-self: center; width: 100%; max-width: 400px; padding: 32px 24px; display: flex; flex-direction: column; gap: 16px }
.login-card h1 { font-size: 34px; margin: 18px 0 6px }
.login-card label { display: flex; flex-direction: column; gap: 6px; font-size: 14px; font-weight: 600 }
.login-card input { padding: 12px 14px; font: inherit; border: 2px solid var(--line); border-radius: 12px; background: var(--card); color: var(--fg) }
.login-card input:focus { outline: none; box-shadow: var(--shadow-sm) }
.login-sub-left { color: var(--mut); margin: 0 }
#actFields { display: flex; flex-direction: column; gap: 16px }
#actFields.hidden { display: none !important }
.login-err { color: #d23b3b; font-size: 14px; margin: 0; min-height: 1em }
.login-help { color: var(--mut); font-size: 13px; margin: 0 }

/* En-tête */
.top { position: sticky; top: 0; z-index: 10; background: var(--paper); border-bottom: 2px solid var(--line) }
.top-in { max-width: 1120px; margin: 0 auto; padding: 0 20px; height: 66px; display: flex; align-items: center; gap: 32px }
.links { display: flex; gap: 6px; flex: 1 }
.links a { padding: 7px 14px; border-radius: 99px; font-weight: 600; color: var(--mut); border: 2px solid transparent }
.links a:hover { color: var(--fg) }
.links a.on { color: var(--fg); border-color: var(--line); background: var(--card) }
.me { position: relative }
.avatar { width: 38px; height: 38px; border-radius: 50%; border: 2px solid var(--line); background: var(--sunset); color: #fff; font-family: var(--head); font-weight: 800 }
.menu { position: absolute; right: 0; top: 48px; background: var(--card); border: 2px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); min-width: 230px; padding: 6px }
.menu-head { padding: 10px 12px; display: flex; flex-direction: column; font-size: 14px; border-bottom: 1px solid var(--soft); margin-bottom: 4px }
.menu-head span { color: var(--mut); font-size: 13px; overflow: hidden; text-overflow: ellipsis }
.menu-item { width: 100%; text-align: left; background: none; border: 0; padding: 9px 12px; border-radius: 9px }
.menu-item:hover { background: var(--soft) }

.wrap { max-width: 1120px; margin: 0 auto; padding: 0 20px }

/* Accueil */
.hero { padding: 56px 0 40px; display: grid; grid-template-columns: 1fr auto; gap: 32px; align-items: end }
.hero h1 { font-size: clamp(40px, 6vw, 68px); margin: 0 0 14px; font-weight: 800 }
.hero p { margin: 0; color: var(--mut); font-size: 18px; max-width: 520px }
.meter { width: 220px; text-align: right }
.meter-num { font-family: var(--head); font-weight: 800; font-size: 56px; line-height: 1 }
.meter-lbl { color: var(--mut); font-size: 14px; margin: 4px 0 10px }
.bar { height: 12px; border: 2px solid var(--line); border-radius: 99px; background: var(--card); overflow: hidden }
.bar > i { display: block; height: 100%; background: var(--ok); transition: width .3s }

.resume { display: flex; align-items: center; gap: 20px; background: var(--ink); color: var(--paper); border-radius: 20px; padding: 22px 26px; margin-bottom: 56px; box-shadow: 6px 6px 0 var(--sunset) }
.resume-k { font-size: 13px; text-transform: uppercase; letter-spacing: .08em; opacity: .7 }
.resume-t { font-family: var(--head); font-weight: 800; font-size: 26px; line-height: 1.15 }
.resume-txt { flex: 1; min-width: 0 }
.resume .btn { background: var(--gold); color: #161412; border-color: var(--gold); box-shadow: none }
.resume:hover .btn { transform: translateX(3px) }

.sec-title { display: flex; align-items: baseline; justify-content: space-between; margin: 0 0 20px }
.sec-title h2 { font-size: 30px; margin: 0 }
.sec-title span { color: var(--mut); font-size: 14px }

.path { position: relative; display: flex; flex-direction: column; gap: 18px; padding-bottom: 80px }
.path::before { content: ""; position: absolute; left: 44px; top: 20px; bottom: 100px; border-left: 3px dashed var(--line); opacity: .35 }
.step { position: relative; display: grid; grid-template-columns: 90px 1fr auto; gap: 22px; align-items: center; background: var(--card); border: 2px solid var(--line); border-radius: 20px; padding: 18px 24px 18px 18px; box-shadow: var(--shadow); transition: transform .1s, box-shadow .1s }
.step:hover { transform: translate(-2px, -2px); box-shadow: 6px 6px 0 var(--ink) }
.step-num { width: 70px; height: 70px; border-radius: 18px; border: 2px solid var(--line); display: grid; place-items: center; font-family: var(--head); font-weight: 800; font-size: 28px; color: #fff; text-shadow: 2px 2px 0 rgba(0,0,0,.35); justify-self: center }
.step h3 { font-size: 24px; margin: 0 0 4px }
.step p { margin: 0; color: var(--mut); font-size: 15px }
.step-meta { display: flex; align-items: center; gap: 12px; margin-top: 10px; font-size: 13px; color: var(--mut) }
.step-meta .bar { width: 140px; height: 9px }
.step-go { font-family: var(--head); font-weight: 800; font-size: 26px; width: 48px; height: 48px; border: 2px solid var(--line); border-radius: 50%; display: grid; place-items: center }
.step.complete .step-go { background: var(--ok); color: #fff }

/* Leçon */
.lesson-page { display: grid; grid-template-columns: 280px 1fr; gap: 48px; padding: 36px 0 90px }
.toc { position: sticky; top: 96px; align-self: start; max-height: calc(100vh - 120px); overflow-y: auto; overflow-x: hidden; padding: 2px 6px 2px 2px }
.toc-back { font-size: 14px; color: var(--mut); display: inline-flex; gap: 6px; margin-bottom: 16px }
.toc-back:hover { color: var(--fg) }
.toc-head { display: flex; align-items: center; gap: 12px; margin-bottom: 8px }
.toc-num { width: 40px; height: 40px; border-radius: 11px; border: 2px solid var(--line); color: #fff; font-family: var(--head); font-weight: 800; display: grid; place-items: center; flex: none }
.toc-head h2 { font-size: 19px; margin: 0 }
.toc .bar { height: 8px; margin: 10px 0 4px }
.toc-pct { font-size: 13px; color: var(--mut); margin-bottom: 14px }
.toc-mod { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .08em; color: var(--mut); margin: 18px 0 6px }
.toc a.item { display: flex; gap: 10px; align-items: flex-start; padding: 7px 10px; border-radius: 10px; font-size: 14.5px; line-height: 1.4 }
.toc a.item:hover { background: var(--soft) }
.toc a.item.on { background: var(--card); border: 2px solid var(--line); padding: 5px 8px; font-weight: 600 }
.tick { width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--line); flex: none; margin-top: 1px; display: grid; place-items: center; opacity: .55 }
.item.done .tick { background: var(--ok); border-color: var(--ok); opacity: 1 }
.item.done .tick::after { content: ""; width: 4px; height: 8px; border: solid #fff; border-width: 0 2px 2px 0; transform: rotate(45deg) translate(-1px, -1px) }
.toc-toggle { display: none }

.article { min-width: 0; max-width: 720px }
.kicker { display: inline-flex; gap: 8px; align-items: center; font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: .08em; padding: 5px 12px; border: 2px solid var(--line); border-radius: 99px; background: var(--card) }
.kicker i { width: 10px; height: 10px; border-radius: 50%; border: 1.5px solid var(--line) }
.article h1 { font-size: clamp(32px, 4.5vw, 48px); font-weight: 800; margin: 18px 0 10px }
.article .meta { color: var(--mut); font-size: 14px; margin-bottom: 28px }
.video { aspect-ratio: 16 / 9; border: 2px solid var(--line); border-radius: 18px; overflow: hidden; box-shadow: var(--shadow); margin-bottom: 32px; background: #000 }
.video iframe { width: 100%; height: 100%; border: 0 }

.body { font-size: 17px }
.body h2 { font-size: 26px; margin: 40px 0 12px }
.body h3 { font-size: 20px; margin: 28px 0 8px }
.body p { margin: 0 0 16px }
.body ul, .body ol { padding-left: 24px; margin: 0 0 18px }
.body li { margin: 5px 0 }
.body li::marker { font-weight: 700 }
.body li.task { list-style: none; margin-left: -24px }
.body li.task label { display: flex; gap: 12px; align-items: flex-start; cursor: pointer }
.body li.task input { appearance: none; width: 20px; height: 20px; border: 2px solid var(--line); border-radius: 6px; margin: 4px 0 0; flex: none; background: var(--card); cursor: pointer }
.body li.task input:checked { background: var(--ok); border-color: var(--ok); box-shadow: inset 0 0 0 3px var(--card) }
.body li.task input:checked + span { text-decoration: line-through; color: var(--mut) }
.body blockquote { margin: 20px 0; padding: 16px 20px; background: var(--gold); color: #161412; border: 2px solid var(--line); border-radius: 14px; box-shadow: var(--shadow-sm); font-weight: 500 }
.body blockquote p { margin: 0 }
.body code { background: var(--soft); padding: 2px 6px; border-radius: 6px; font-size: 14px }
.body strong { font-weight: 700 }
.body table { border-collapse: separate; border-spacing: 0; width: 100%; margin: 8px 0 20px; font-size: 15px; border: 2px solid var(--line); border-radius: 14px; overflow: hidden; background: var(--card) }
.body th, .body td { padding: 10px 14px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--soft) }
.body tr:last-child td { border-bottom: 0 }
.body th { background: var(--soft); font-size: 13px; text-transform: uppercase; letter-spacing: .05em }
.code { position: relative; margin: 8px 0 22px }
.code pre { background: #161412; color: #f1ead9; border: 2px solid var(--line); border-radius: 14px; padding: 46px 20px 18px; margin: 0; overflow: auto; white-space: pre-wrap; font-size: 14px; line-height: 1.6; box-shadow: var(--shadow-sm) }
.code pre code { background: none; padding: 0; font-size: inherit }
.copy { position: absolute; top: 10px; right: 10px; padding: 5px 12px; font-size: 13px; border-radius: 9px; background: var(--gold); color: #161412; border-color: #161412; box-shadow: none }
.empty { color: var(--mut); font-style: italic }

/* Prompt à donner à l'agent */
.code.agent { border: 2px solid var(--line); border-radius: 16px; background: #2f6fd6; box-shadow: var(--shadow); overflow: hidden }
.agent-head { color: #fff; font-family: var(--head); font-weight: 800; font-size: 16px; padding: 10px 12px 10px 18px; display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap }
.code.agent pre { border: 0; border-top: 2px solid var(--line); border-radius: 0; box-shadow: none; padding: 18px 20px; max-height: 420px }
.code.agent .copy { position: static; padding: 8px 16px; font-size: 14px; box-shadow: var(--shadow-sm); border: 2px solid #161412 }

/* Infographies */
.infog { margin: 8px 0 24px }
.infog img { width: 100%; display: block; border: 2px solid var(--line); border-radius: 16px; box-shadow: var(--shadow-sm) }
.infog figcaption { color: var(--mut); font-size: 14px; margin-top: 8px }
.infog-todo { margin: 8px 0 24px; padding: 22px; border: 2px dashed var(--line); border-radius: 16px; display: flex; flex-direction: column; gap: 4px; background: var(--soft) }
.infog-todo strong { font-family: var(--head); font-size: 15px }
.infog-todo span { color: var(--mut); font-size: 15px }

.refs { margin-top: 44px; padding-top: 28px; border-top: 2px dashed var(--line) }
.refs h2 { font-size: 24px; margin: 0 0 18px }
.ref { margin: 0 0 24px }
.ref-video { aspect-ratio: 16 / 9; border: 2px solid var(--line); border-radius: 16px; overflow: hidden; box-shadow: var(--shadow-sm); background: #000 }
.ref-video iframe { width: 100%; height: 100%; border: 0 }
.ref figcaption { margin-top: 10px; display: flex; flex-direction: column; gap: 2px }
.ref figcaption strong { font-size: 16px }
.ref figcaption span { color: var(--mut); font-size: 14px }
.ref figcaption p { margin: 4px 0 0; font-size: 15px }
.finish { margin-top: 48px; display: flex; flex-direction: column; gap: 14px }
.next-card { display: flex; align-items: center; gap: 18px; padding: 20px 24px; background: var(--card); border: 2px solid var(--line); border-radius: 18px; box-shadow: var(--shadow); text-align: left; width: 100% }
.next-card:hover { transform: translate(-2px, -2px); box-shadow: 6px 6px 0 var(--ink) }
.next-k { font-size: 13px; color: var(--mut) }
.next-t { font-family: var(--head); font-weight: 800; font-size: 22px; line-height: 1.2 }
.next-txt { flex: 1; min-width: 0 }
.next-arrow { font-family: var(--head); font-weight: 800; font-size: 28px }
.finish-row { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap }

/* Ressources, contact */
.page { padding: 56px 0 90px }
.page h1 { font-size: clamp(36px, 5vw, 56px); font-weight: 800; margin: 0 0 10px }
.page > p { color: var(--mut); font-size: 18px; margin: 0 0 32px; max-width: 560px }
.res { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px }
.res a { background: var(--card); border: 2px solid var(--line); border-radius: 18px; padding: 20px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 4px; transition: transform .1s, box-shadow .1s }
.res a:hover { transform: translate(-2px, -2px); box-shadow: 6px 6px 0 var(--ink) }
.res strong { font-family: var(--head); font-size: 20px }
.res span { color: var(--mut); font-size: 14.5px }
.panel { background: var(--card); border: 2px solid var(--line); border-radius: 20px; padding: 28px; box-shadow: var(--shadow); max-width: 620px }
.panel p { margin: 0 0 18px; font-size: 17px }

@media (max-width: 900px) {
  .login { grid-template-columns: 1fr }
  .login-art { min-height: 220px; border-right: 0; border-bottom: 2px solid var(--line); padding: 24px }
  .sun { width: 110px; height: 110px; top: 14%; left: 78% }
  .login-quote { font-size: 22px }
  .lesson-page { grid-template-columns: 1fr; gap: 24px; padding-top: 20px }
  .toc { position: static; max-height: none; background: var(--card); border: 2px solid var(--line); border-radius: 18px; padding: 16px 18px; box-shadow: var(--shadow-sm) }
  .toc.collapsed .toc-list { display: none }
  .toc-toggle { display: inline-flex; margin-top: 4px; padding: 6px 12px; font-size: 14px }
  .res { grid-template-columns: 1fr 1fr }
}
@media (max-width: 640px) {
  .top-in { gap: 10px; padding: 0 16px; height: 60px }
  .logo-txt { display: none }
  .links a { padding: 6px 10px; font-size: 14px }
  .wrap { padding: 0 16px }
  .hero { grid-template-columns: 1fr; padding: 32px 0 26px; gap: 22px }
  .meter { width: 100%; text-align: left }
  .meter-num { font-size: 42px }
  .resume { flex-direction: column; align-items: flex-start; gap: 14px; padding: 20px; margin-bottom: 40px }
  .resume-t { font-size: 22px }
  .resume .btn { width: 100% }
  .sec-title span { display: none }
  .path::before { left: 38px }
  .step { grid-template-columns: 56px 1fr; padding: 16px; gap: 14px }
  .step-num { width: 56px; height: 56px; font-size: 22px; border-radius: 14px }
  .step h3 { font-size: 20px }
  .step-go { display: none }
  .step-meta .bar { width: 90px }
  .body { font-size: 16px }
  .res { grid-template-columns: 1fr }
  .next-t { font-size: 19px }
}
