:root {
  --bg: #f6f2ea;
  --bg-2: #efe9de;
  --card: #fffdf8;
  --ink: #1c1a17;
  --ink-2: #4a453d;
  --ink-3: #7d766b;
  --line: #ddd5c7;
  --accent: #2f6b4f;
  --accent-2: #dcebe2;
  --yang: #1c1a17;
  --ok: #3b6b4f;
  --radius: 10px;
  --font: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #171512; --bg-2: #1f1c18; --card: #24211c; --ink: #ece6da; --ink-2: #c7bfb1; --ink-3: #8f877a;
    --line: #3a352d; --accent: #d9784c; --accent-2: #3d2a20; --yang: #ece6da; --ok: #7fb593;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: var(--sans); font-size: 16px; line-height: 1.55;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { font-family: var(--font); font-weight: 600; line-height: 1.2; margin: 0 0 .4em; }
h1 { font-size: 2rem; }
h2 { font-size: 1.45rem; }
h3 { font-size: 1.15rem; }
p { margin: 0 0 1em; }
.muted { color: var(--ink-3); }
.small { font-size: .88rem; }

.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 14px 20px; border-bottom: 1px solid var(--line); background: var(--bg);
  position: sticky; top: 0; z-index: 10; flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); font-family: var(--font); font-size: 1.15rem; font-weight: 600; }
.brand:hover { text-decoration: none; }
.brand-mark { width: 26px; height: 26px; fill: var(--ink); }
.nav { display: flex; gap: 4px; flex-wrap: wrap; }
.nav a { color: var(--ink-2); padding: 6px 10px; border-radius: 6px; font-size: .95rem; }
.nav a:hover { background: var(--bg-2); text-decoration: none; }
.nav a.active { background: var(--ink); color: var(--bg); }

.app { max-width: 880px; margin: 0 auto; padding: 28px 16px 60px; }
.foot { max-width: 880px; margin: 0 auto; padding: 24px 16px 40px; color: var(--ink-3); font-size: .85rem; border-top: 1px solid var(--line); }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px 22px; margin-bottom: 18px; }
.card.accent { border-left: 4px solid var(--accent); }
.card h3 { margin-top: 0; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
@media (max-width: 700px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }

.btn {
  display: inline-block; padding: 10px 18px; border-radius: 8px; border: 1px solid var(--ink);
  background: var(--ink); color: var(--bg); font: inherit; font-weight: 600; cursor: pointer;
}
.btn:hover { opacity: .9; text-decoration: none; }
.btn.secondary { background: transparent; color: var(--ink); }
.btn.secondary:hover { background: var(--bg-2); }
.btn.small { padding: 6px 12px; font-size: .88rem; font-weight: 500; }
.btn:disabled { opacity: .45; cursor: default; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-top: 10px; }

input[type=text], textarea, select {
  width: 100%; font: inherit; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--card); color: var(--ink);
}
textarea { min-height: 110px; resize: vertical; }
label.field { display: block; margin-bottom: 14px; }
label.field > span { display: block; font-weight: 600; margin-bottom: 6px; }
.hint { color: var(--ink-3); font-size: .88rem; margin-top: 4px; }

/* Hexagramme */
.hex { display: inline-block; vertical-align: middle; }
.hex .l { fill: var(--yang); }
.hex .m { fill: var(--accent); }
.hex-big { width: 120px; }
.hex-mid { width: 72px; }
.hex-small { width: 44px; }
.hex-head { display: flex; gap: 22px; align-items: center; flex-wrap: wrap; }
.hex-head .hex-title h1 { margin-bottom: .1em; }
.hex-head .kicker { color: var(--ink-3); font-size: .9rem; letter-spacing: .02em; }
.hex-head .cn { font-family: "Songti SC", "Noto Serif CJK SC", "SimSun", serif; font-size: 1.6rem; color: var(--ink-2); margin-left: 8px; }
.trig { display: flex; gap: 18px; flex-wrap: wrap; margin: 10px 0 0; color: var(--ink-2); font-size: .92rem; }
.trig span b { font-weight: 600; }

/* Positions */
.pos-list { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }
.pos-list li { display: grid; grid-template-columns: 34px 1fr; gap: 12px; align-items: start; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--card); }
.pos-list li.me { border-color: var(--accent); background: var(--accent-2); }
.pos-list li.moving .num { color: var(--accent); }
.pos-list .num { font-family: var(--font); font-size: 1.3rem; font-weight: 600; color: var(--ink-3); text-align: center; line-height: 1.2; }
.pos-list .role { display: block; font-size: .82rem; color: var(--ink-3); margin-bottom: 2px; }
.tag { display: inline-block; font-size: .74rem; padding: 2px 7px; border-radius: 99px; background: var(--bg-2); color: var(--ink-2); margin-left: 6px; vertical-align: middle; }
.tag.accent { background: var(--accent); color: #fff; }

/* Questionnaire */
.steps { display: flex; gap: 6px; margin-bottom: 18px; }
.steps span { flex: 1; height: 4px; border-radius: 2px; background: var(--line); }
.steps span.done { background: var(--ink); }
.q { padding: 18px 0; border-top: 1px solid var(--line); }
.q:first-of-type { border-top: 0; }
.q .q-kicker { color: var(--ink-3); font-size: .82rem; text-transform: uppercase; letter-spacing: .06em; }
.q h3 { margin: 4px 0 10px; }
.choice { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
@media (max-width: 560px) { .choice { grid-template-columns: 1fr; } }
.choice label { display: block; padding: 12px 14px; border: 1px solid var(--line); border-radius: 8px; cursor: pointer; background: var(--card); }
.choice label:hover { border-color: var(--ink-3); }
.choice label.on { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }
.choice input { display: none; }
.choice .ch-name { font-weight: 600; display: block; margin-bottom: 3px; }
.choice .ch-desc { color: var(--ink-2); font-size: .9rem; }
.mut { margin-top: 10px; display: flex; align-items: center; gap: 8px; color: var(--ink-2); font-size: .92rem; cursor: pointer; }
.mut input { width: 18px; height: 18px; accent-color: var(--accent); }
.roles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
@media (max-width: 640px) { .roles { grid-template-columns: 1fr 1fr; } }
.roles label { display: block; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; cursor: pointer; background: var(--card); font-size: .92rem; }
.roles label.on { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }
.roles input { display: none; }
.roles b { display: block; }
.roles small { color: var(--ink-3); }

/* Tirage */
.coins { display: grid; gap: 8px; margin: 14px 0; }
.coin-row { display: grid; grid-template-columns: 40px 1fr auto; gap: 12px; align-items: center; padding: 8px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--card); }
.coin-row.empty { opacity: .5; }
.coin-row .cv { font-family: var(--font); font-weight: 600; font-size: 1.2rem; text-align: center; }
.coin-row .cl { font-size: .9rem; color: var(--ink-2); }
.coin-row .faces { letter-spacing: .15em; color: var(--ink-3); font-size: .85rem; }
.manual { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; }
.manual select { padding: 8px; }

/* Bibliothèque */
.lib-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px; }
.lib-item { display: flex; gap: 12px; align-items: center; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--card); color: var(--ink); }
.lib-item:hover { border-color: var(--ink-3); text-decoration: none; }
.lib-item .li-n { color: var(--ink-3); font-size: .78rem; }
.lib-item .li-t { font-weight: 600; font-size: .92rem; line-height: 1.25; }
.lib-item .li-s { color: var(--ink-3); font-size: .8rem; }
.search { margin-bottom: 14px; }

/* Dérivés */
.deriv { display: flex; gap: 14px; align-items: center; padding: 12px 14px; border: 1px solid var(--line); border-radius: 8px; background: var(--card); color: var(--ink); }
.deriv:hover { border-color: var(--ink-3); text-decoration: none; }
.deriv .d-k { font-size: .78rem; color: var(--ink-3); text-transform: uppercase; letter-spacing: .05em; }
.deriv .d-t { font-weight: 600; }
.deriv .d-s { font-size: .85rem; color: var(--ink-2); }

/* Journal */
.j-item { padding: 16px 18px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); margin-bottom: 12px; }
.j-item .j-head { display: flex; gap: 14px; align-items: flex-start; }
.j-item .j-meta { color: var(--ink-3); font-size: .85rem; }
.j-item h3 { margin: 0 0 4px; }
.j-item .j-desc { white-space: pre-wrap; margin: 8px 0; color: var(--ink-2); }
.badge { display: inline-block; padding: 2px 8px; border-radius: 99px; font-size: .75rem; background: var(--accent); color: #fff; }
.badge.soft { background: var(--bg-2); color: var(--ink-2); }
.relecture { margin-top: 10px; padding: 10px 12px; border-left: 3px solid var(--ok); background: var(--bg-2); border-radius: 0 8px 8px 0; white-space: pre-wrap; }

.hero { padding: 30px 0 10px; }
.hero h1 { font-size: 2.4rem; margin-bottom: .3em; }
.hero p.lead { font-size: 1.12rem; color: var(--ink-2); max-width: 640px; }
.entry { display: block; padding: 18px 20px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); color: var(--ink); height: 100%; }
.entry:hover { border-color: var(--ink); text-decoration: none; }
.entry h3 { margin-bottom: 4px; }
.entry p { margin: 0; color: var(--ink-2); font-size: .93rem; }
.quote { font-family: var(--font); font-size: 1.15rem; color: var(--ink-2); font-style: italic; }
.notice { padding: 10px 14px; border-radius: 8px; background: var(--accent-2); color: var(--ink); font-size: .92rem; margin-bottom: 14px; }
.sr { position: absolute; left: -9999px; }
.spacer { height: 10px; }
hr.sep { border: 0; border-top: 1px solid var(--line); margin: 22px 0; }
details summary { cursor: pointer; font-weight: 600; }
.mono { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .9em; }

/* Cinq Agir */
:root { --bois:#3f7d4e; --feu:#c0392b; --terre:#c9962b; --metal:#8a8f99; --eau:#2b5c8a; }
.penta { width:100%; max-width:560px; margin:0 auto; display:block; }
.penta .node { cursor:pointer; }
.penta .node circle { stroke:var(--card); stroke-width:3; transition:r .15s; }
.penta .node:hover circle { r:34; }
.penta .node text { fill:#fff; font-weight:700; font-size:15px; text-anchor:middle; dominant-baseline:middle; pointer-events:none; font-family:var(--sans); }
.penta .node text.lbl { fill:var(--ink-3); font-size:11.5px; font-weight:500; font-family:var(--sans); }
.penta .arrow { fill:none; stroke-width:2.2; stroke-linecap:round; }
.penta .arrow.nourrit { stroke:var(--ink-2); }
.penta .arrow.finalise { stroke:var(--ink-3); stroke-dasharray:5 4; }
.penta .arrow.controle { stroke:var(--accent); }
.penta .arrow.dim { opacity:.18; }
.penta .arrow.hot { stroke-width:3.5; }
.penta .node.dim { opacity:.35; }
.penta .node.hot circle { stroke:var(--ink); }
.legend { display:flex; gap:14px; flex-wrap:wrap; justify-content:center; font-size:.85rem; color:var(--ink-2); margin-top:6px; }
.legend span::before { content:""; display:inline-block; width:22px; height:0; border-top:2.5px solid var(--ink-2); margin-right:6px; vertical-align:middle; }
.legend .fin::before { border-top-style:dashed; border-color:var(--ink-3); }
.legend .ctl::before { border-color:var(--accent); }
.dot { display:inline-block; width:12px; height:12px; border-radius:50%; vertical-align:middle; margin-right:6px; }
.c-bois { background:var(--bois); } .c-feu { background:var(--feu); } .c-terre { background:var(--terre); } .c-metal { background:var(--metal); } .c-eau { background:var(--eau); }
.tint-bois { border-left:5px solid var(--bois); } .tint-feu { border-left:5px solid var(--feu); } .tint-terre { border-left:5px solid var(--terre); } .tint-metal { border-left:5px solid var(--metal); } .tint-eau { border-left:5px solid var(--eau); }
.likert { display:grid; grid-template-columns:repeat(5,1fr); gap:6px; margin-top:8px; }
.likert label { text-align:center; padding:8px 4px; border:1px solid var(--line); border-radius:8px; cursor:pointer; font-size:.8rem; color:var(--ink-2); background:var(--card); }
.likert label.on { background:var(--ink); color:var(--bg); border-color:var(--ink); }
.likert input { display:none; }
.q-item { padding:14px 0; border-top:1px solid var(--line); }
.q-item:first-child { border-top:0; }
.q-item p { margin:0; }
.check { display:flex; gap:10px; align-items:flex-start; padding:9px 12px; border:1px solid var(--line); border-radius:8px; background:var(--card); cursor:pointer; margin-bottom:8px; }
.check input { width:18px; height:18px; margin-top:2px; accent-color:var(--accent); flex:none; }
.check.on { border-color:var(--ink); }
.radar { width:100%; max-width:380px; display:block; margin:0 auto; }
.radar .grid { fill:none; stroke:var(--line); }
.radar .axis { stroke:var(--line); }
.radar .shape { fill:rgba(122,92,30,.18); stroke:var(--accent); stroke-width:2; }
.radar text { font-size:11px; fill:var(--ink-2); text-anchor:middle; font-family:var(--sans); }
.bars { display:grid; gap:8px; }
.bar { display:grid; grid-template-columns:70px 1fr 40px; gap:10px; align-items:center; font-size:.9rem; }
.bar .track { height:10px; background:var(--bg-2); border-radius:5px; overflow:hidden; }
.bar .fill { height:100%; border-radius:5px; }
.rel-list { display:grid; gap:8px; }
.rel { display:flex; gap:12px; align-items:center; padding:10px 12px; border:1px solid var(--line); border-radius:8px; background:var(--card); color:var(--ink); }
.rel:hover { border-color:var(--ink-3); text-decoration:none; }
.rel .rk { font-size:.75rem; color:var(--ink-3); text-transform:uppercase; letter-spacing:.05em; }
.rel .rt { font-weight:600; }
.slider { display:grid; grid-template-columns:90px 1fr 34px; gap:12px; align-items:center; margin-bottom:10px; }
.slider input[type=range] { width:100%; accent-color:var(--accent); }
.crea-panel textarea { min-height:90px; }
.step-title { display:flex; align-items:center; gap:10px; }
.step-title .n { width:28px; height:28px; border-radius:50%; background:var(--ink); color:var(--bg); display:inline-flex; align-items:center; justify-content:center; font-weight:700; font-size:.85rem; }

details.livre { border-top:1px solid var(--line); padding:10px 0 0; margin-top:10px; }
details.livre:first-child { border-top:0; margin-top:0; padding-top:0; }
details.livre > summary { cursor:pointer; font-weight:600; font-family:var(--font); font-size:1.02rem; color:var(--ink); list-style:none; padding-left:18px; position:relative; }
details.livre > summary::-webkit-details-marker { display:none; }
details.livre > summary::before { content:"›"; position:absolute; left:2px; top:-1px; color:var(--accent); font-size:1.2rem; transition:transform .15s; }
details.livre[open] > summary::before { transform:rotate(90deg); }
.livre-body { padding-top:8px; }
.livre-body p { font-size:.97rem; }
table.syn { width:100%; border-collapse:collapse; font-size:.93rem; }
table.syn th { text-align:left; font-weight:600; color:var(--ink-2); padding:7px 12px 7px 0; vertical-align:top; width:34%; border-top:1px solid var(--line); }
table.syn td { padding:7px 0; vertical-align:top; border-top:1px solid var(--line); }
table.syn tr:first-child th, table.syn tr:first-child td { border-top:0; }
.table-scroll { overflow-x:auto; }
table.syn.ind th, table.syn.ind td { width:auto; padding-right:10px; font-size:.86rem; min-width:120px; }
.q { margin:0 0 6px; padding-left:14px; position:relative; font-size:.95rem; }
.q::before { content:""; position:absolute; left:0; top:.6em; width:6px; height:6px; border-radius:50%; background:var(--accent); }
.qs { margin:8px 0 10px; }
.ws textarea { margin-top:4px; }
.compl { background:var(--bg-2); }
.likert.l3 { grid-template-columns:repeat(3,1fr); }
.poeme p { font-family:var(--font); font-style:italic; line-height:1.6; padding-left:14px; margin-bottom:1.1em; }
.hero .kicker { font-size:.9rem; letter-spacing:.03em; margin-bottom:6px; }

figure.appert { margin:14px 0 0; background:#fff; border-radius:8px; padding:10px; text-align:center; }
figure.appert img { max-width:100%; max-height:170px; height:auto; }
figure.appert.big img { max-height:340px; }
figure.appert figcaption { font-size:.8rem; color:#6b645a; margin-top:6px; }
.agir-card figure.appert { float:right; width:150px; margin:0 0 8px 16px; padding:6px; }
.agir-card figure.appert img { max-height:120px; }
.agir-card::after { content:""; display:block; clear:both; }
@media (max-width:560px){ .agir-card figure.appert { float:none; width:auto; margin:0 0 10px; } }
.frise { display:grid; grid-template-columns:repeat(5,1fr); gap:10px; margin:6px 0 14px; }
.frise a { background:#fff; border:1px solid var(--line); border-radius:8px; padding:8px; text-align:center; color:var(--ink-2); font-size:.82rem; }
.frise a:hover { border-color:var(--ink-3); text-decoration:none; }
.frise img { width:100%; height:110px; object-fit:contain; display:block; margin-bottom:4px; }
@media (max-width:560px){ .frise { grid-template-columns:repeat(5,1fr); gap:4px; } .frise a { padding:3px; font-size:.7rem; } .frise img { height:56px; } }

/* Animaux créatifs */
.dessin { background:#fff; border-radius:8px; padding:10px; text-align:center; margin:10px 0; }
.dessin img { max-width:100%; max-height:300px; height:auto; }
.dessin.small img { max-height:180px; }
.phases { display:grid; grid-template-columns:repeat(3,1fr); gap:14px; }
@media (max-width:700px){ .phases { grid-template-columns:1fr; } }
.phase { background:var(--card); border:1px solid var(--line); border-radius:var(--radius); padding:14px; color:var(--ink); display:block; }
.phase:hover { border-color:var(--ink-3); text-decoration:none; }
.phase .dessin { margin:0 0 10px; padding:6px; }
.phase .dessin img { max-height:150px; }
.stepper { display:flex; gap:6px; flex-wrap:wrap; margin:0 0 16px; }
.stepper a { padding:6px 11px; border-radius:99px; border:1px solid var(--line); background:var(--card); color:var(--ink-2); font-size:.85rem; }
.stepper a.on { background:var(--ink); color:var(--bg); border-color:var(--ink); }
.stepper a.done { border-color:var(--accent); color:var(--accent); }
.code { display:inline-block; min-width:30px; padding:1px 7px; border-radius:6px; background:var(--accent); color:#fff; font-size:.78rem; font-weight:700; text-align:center; margin-right:8px; vertical-align:middle; }
.terr-list { display:grid; gap:6px; }
.terr { display:flex; gap:10px; align-items:flex-start; padding:8px 12px; border:1px solid var(--line); border-radius:8px; background:var(--card); cursor:pointer; font-size:.93rem; }
.terr input { width:17px; height:17px; margin-top:2px; accent-color:var(--accent); flex:none; }
.terr.on { border-color:var(--accent); background:var(--accent-2); }
.terr .star { margin-left:auto; border:0; background:none; font-size:1.2rem; cursor:pointer; color:var(--ink-3); line-height:1; }
.terr.kept { border-color:var(--ink); box-shadow:inset 0 0 0 1px var(--ink); }
.terr.kept .star { color:#c9962b; }
.animal { display:grid; grid-template-columns:260px 1fr; gap:18px; align-items:start; }
@media (max-width:640px){ .animal { grid-template-columns:1fr; } }
.photo { margin:0; }
.photo img { width:100%; border-radius:8px; display:block; background:var(--bg-2); aspect-ratio:4/3; object-fit:cover; }
.photo figcaption { font-size:.72rem; color:var(--ink-3); margin-top:4px; line-height:1.3; }
.photo figcaption a { color:var(--ink-3); text-decoration:underline; }
.invention { font-family:var(--font); font-size:1.12rem; line-height:1.5; }
.bestiaire { display:grid; grid-template-columns:repeat(auto-fill,minmax(170px,1fr)); gap:12px; }
.bestiaire a { background:var(--card); border:1px solid var(--line); border-radius:10px; overflow:hidden; color:var(--ink); display:flex; flex-direction:column; }
.bestiaire a:hover { border-color:var(--ink-3); text-decoration:none; }
.bestiaire img { width:100%; aspect-ratio:4/3; object-fit:cover; display:block; background:var(--bg-2); }
.bestiaire .bn { padding:8px 10px 2px; font-weight:600; font-size:.92rem; }
.bestiaire .bt { padding:0 10px 10px; font-size:.78rem; color:var(--ink-3); line-height:1.35; }
.links { display:flex; gap:8px; flex-wrap:wrap; margin-top:10px; }
.quiz .rep { display:none; margin-top:10px; padding:10px 12px; border-left:3px solid var(--accent); background:var(--bg-2); border-radius:0 8px 8px 0; }
.quiz.open .rep { display:block; }
.ex-list p { margin:0 0 4px; padding-left:14px; position:relative; }
.ex-list p::before { content:"✓"; position:absolute; left:0; color:var(--accent); font-size:.8rem; }

figure.clip { margin:12px 0 0; }
figure.clip video { width:100%; max-height:420px; border-radius:8px; background:#000; display:block; }
figure.clip figcaption { font-size:.72rem; color:var(--ink-3); margin-top:4px; }
figure.clip figcaption a { color:var(--ink-3); text-decoration:underline; }
.vbadge { display:inline-block; font-size:.62rem; background:var(--accent); color:#fff; border-radius:4px; padding:1px 5px; vertical-align:middle; }

.qq { margin:0 0 6px; padding-left:14px; position:relative; font-size:.95rem; }
.qq::before { content:""; position:absolute; left:0; top:.6em; width:6px; height:6px; border-radius:50%; background:var(--accent); }
