/* Fiches Bac STI2D — thème « Abysse » (palette ChatX) */
:root {
  --backdrop: #15161b; --sunken: #111319; --ground: #15161b; --raised: #1b1e26;
  --card: #242833; --hover: #2e3442; --strong: #6d7890; --line: #424b5e;
  --fg: #eef1f8; --dim: #d2d9e6; --faint: #b3bfd3; --accent: #8db7ff;
  --blue: #60a5fa; --cyan: #22d3ee; --green: #4ade80; --yellow: #facc15;
  --orange: #fb923c; --pink: #f472b6; --violet: #a78bfa; --red: #f87171; --teal: #2dd4bf;
  --mat: var(--accent);
  --font-sans: "Inter Variable", "Inter", "Segoe UI Variable Text", "Segoe UI", system-ui, sans-serif;
  --font-mono: "Cascadia Code", "Cascadia Mono", Consolas, monospace;
  --font-math: "Cambria Math", "STIX Two Math", Cambria, "Times New Roman", serif;
  --r-sm: 6px; --r-md: 9px; --r-lg: 12px; --r-xl: 16px; --r-2xl: 20px;
  --lift: inset 0 1px 0 #ffffff0f, 0 16px 40px #00000059;
  color-scheme: dark;
}
[data-mat="maths"] { --mat: var(--blue); }
[data-mat="maths-spe"] { --mat: var(--violet); }
[data-mat="pc"] { --mat: var(--cyan); }
[data-mat="i2d"] { --mat: var(--orange); }
[data-mat="methode"] { --mat: var(--green); }

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 18px; }
body {
  margin: 0; background: var(--backdrop); color: var(--fg);
  font: 15.5px/1.6 var(--font-sans); -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
::selection { background: #8db7ff55; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--line); border-radius: 10px; border: 2px solid var(--raised); }
::-webkit-scrollbar-track { background: transparent; }

/* ---------- Coque ---------- */
.shell { display: grid; grid-template-columns: 290px minmax(0, 1fr); gap: 10px; padding: 10px; min-height: 100vh; }
.side {
  position: sticky; top: 10px; height: calc(100vh - 20px); overflow: auto;
  background: var(--raised); border: 1px solid var(--line); border-radius: var(--r-2xl);
  box-shadow: var(--lift); padding: 16px 12px;
}
.main { background: var(--ground); border: 1px solid var(--line); border-radius: var(--r-2xl); box-shadow: var(--lift); padding: 28px clamp(16px, 4vw, 54px) 80px; min-width: 0; }

.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 14px; color: var(--fg); }
.brand:hover { text-decoration: none; }
.brand-logo { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: var(--sunken); border: 1px solid var(--line); color: var(--mat); font-weight: 800; }
.brand b { display: block; font-size: 14px; }
.brand small { color: var(--faint); font-size: 12px; }

.side-search { width: 100%; padding: 9px 12px; border-radius: var(--r-lg); border: 1px solid var(--line); background: var(--sunken); color: var(--fg); font: inherit; font-size: 14px; outline: none; }
.side-search:focus { border-color: var(--mat); }
.side h4 { margin: 18px 8px 6px; font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--strong); }
.toc { list-style: none; margin: 0; padding: 0; }
.toc a { display: flex; align-items: center; gap: 9px; padding: 7px 9px; border-radius: var(--r-md); color: var(--dim); font-size: 14px; line-height: 1.3; }
.toc a:hover { background: var(--hover); text-decoration: none; color: var(--fg); }
.toc a.active { background: var(--sunken); color: var(--mat); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--mat) 55%, transparent); font-weight: 650; }
.toc .num { flex: none; width: 26px; height: 22px; border-radius: 7px; display: grid; place-items: center; font-size: 11.5px; font-weight: 750; background: var(--card); color: var(--mat); }
.toc .done .num { background: color-mix(in srgb, var(--green) 25%, var(--card)); color: var(--green); }
.toc .done .num::after { content: "✓"; }
.toc .done .num span { display: none; }
.mat-links a { display: flex; align-items: center; gap: 9px; padding: 7px 9px; border-radius: var(--r-md); color: var(--dim); font-size: 14px; }
.mat-links a:hover { background: var(--hover); text-decoration: none; }
.mat-links a.here { color: var(--fg); background: var(--card); }
.dot { width: 9px; height: 9px; border-radius: 50%; flex: none; }

.side-tools { display: grid; gap: 8px; margin-top: 16px; padding: 0 4px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; cursor: pointer;
  padding: 8px 12px; border-radius: var(--r-lg); border: 1px solid var(--line);
  background: var(--card); color: var(--dim); font: inherit; font-size: 13.5px; font-weight: 600;
}
.btn:hover { background: var(--hover); color: var(--fg); text-decoration: none; }
.btn.on { color: var(--mat); background: var(--sunken); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--mat) 65%, transparent); }
.progress { height: 8px; border-radius: 9px; background: var(--sunken); overflow: hidden; border: 1px solid var(--line); }
.progress > i { display: block; height: 100%; width: 0; background: var(--mat); border-radius: 9px; transition: width .4s; }
.prog-label { font-size: 12px; color: var(--faint); display: flex; justify-content: space-between; }

/* ---------- En-tête de page ---------- */
.page-head { display: flex; flex-wrap: wrap; gap: 18px; align-items: flex-end; justify-content: space-between; margin-bottom: 26px; }
.eyebrow { display: inline-flex; gap: 8px; align-items: center; color: var(--mat); font-weight: 700; font-size: 13px; letter-spacing: .06em; text-transform: uppercase; }
h1 { font-size: clamp(28px, 4vw, 40px); line-height: 1.12; margin: 6px 0 8px; letter-spacing: -.02em; }
.lead { color: var(--dim); max-width: 760px; margin: 0; }
.legend { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 99px; font-size: 12.5px; font-weight: 650; background: var(--sunken); border: 1px solid var(--line); color: var(--dim); }

/* ---------- Fiche (chapitre) ---------- */
.fiche { background: var(--raised); border: 1px solid var(--line); border-radius: var(--r-2xl); padding: 26px clamp(16px, 3vw, 34px) 30px; margin: 0 0 26px; box-shadow: var(--lift); }
.fiche-head { display: flex; gap: 16px; align-items: flex-start; margin-bottom: 16px; }
.fiche-num { flex: none; width: 52px; height: 52px; border-radius: 15px; display: grid; place-items: center; font-weight: 800; font-size: 19px; color: var(--mat); background: var(--sunken); border: 1px solid color-mix(in srgb, var(--mat) 55%, var(--line)); }
.fiche-head h2 { margin: 0; font-size: 25px; line-height: 1.2; letter-spacing: -.01em; }
.fiche-meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.fiche-head .btn { margin-left: auto; flex: none; }
.master.on { color: var(--green); box-shadow: inset 0 0 0 1px #4ade8099; }
h3 { font-size: 17px; margin: 26px 0 10px; display: flex; align-items: center; gap: 9px; color: var(--fg); }
h3::before { content: ""; width: 4px; height: 18px; border-radius: 3px; background: var(--mat); }
p { margin: 8px 0; }
ul, ol { padding-left: 22px; margin: 8px 0; }
li { margin: 4px 0; }
strong { color: var(--fg); }
.hl { color: var(--mat); font-weight: 700; }
.muted { color: var(--faint); }
.small { font-size: 13.5px; }

/* résumé 30 s */
.flash30 { background: linear-gradient(135deg, color-mix(in srgb, var(--mat) 16%, var(--card)), var(--card)); border: 1px solid color-mix(in srgb, var(--mat) 45%, var(--line)); border-radius: var(--r-xl); padding: 14px 18px; }
.flash30 > b { display: block; font-size: 12px; letter-spacing: .08em; text-transform: uppercase; color: var(--mat); margin-bottom: 4px; }
.flash30 ul { margin: 0; }

/* grilles */
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(290px, 1fr)); gap: 14px; }
.grid3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }

/* boîtes */
.box { background: var(--card); border: 1px solid var(--line); border-radius: var(--r-xl); padding: 14px 16px; margin: 12px 0; position: relative; }
.box > .tag { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: 12px; font-weight: 750; letter-spacing: .05em; text-transform: uppercase; margin-bottom: 6px; }
.box > :last-child { margin-bottom: 0; }
.def { border-left: 4px solid var(--blue); } .def > .tag { color: var(--blue); }
.prop { border-left: 4px solid var(--violet); } .prop > .tag { color: var(--violet); }
.tip { border-left: 4px solid var(--yellow); background: color-mix(in srgb, var(--yellow) 7%, var(--card)); } .tip > .tag { color: var(--yellow); }
.piege { border-left: 4px solid var(--red); background: color-mix(in srgb, var(--red) 8%, var(--card)); } .piege > .tag { color: var(--red); }
.methode { border-left: 4px solid var(--green); } .methode > .tag { color: var(--green); }
.redac { border-left: 4px solid var(--pink); } .redac > .tag { color: var(--pink); }
.cours { border-left: 4px solid var(--teal); } .cours > .tag { color: var(--teal); }

ol.steps { list-style: none; counter-reset: s; padding: 0; }
ol.steps > li { counter-increment: s; position: relative; padding-left: 38px; margin: 9px 0; }
ol.steps > li::before { content: counter(s); position: absolute; left: 0; top: 0; width: 26px; height: 26px; border-radius: 8px; display: grid; place-items: center; font-weight: 800; font-size: 13px; color: #10131a; background: var(--green); }

/* formules */
.formules { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 10px; margin: 12px 0; }
.fx { background: var(--sunken); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 10px 14px; }
.fx small { display: block; color: var(--faint); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; }
.f { font-family: var(--font-math); font-size: 19px; color: var(--fg); display: inline-block; transition: filter .2s; }
.fx .f { display: block; margin-top: 2px; }
.big { font-size: 23px; }
.m { font-family: var(--font-math); font-size: 1.12em; white-space: nowrap; }
p.m, div.m, li > .m:only-child { white-space: normal; }
.box, .fx { overflow-wrap: anywhere; }
.frac { display: inline-flex; flex-direction: column; vertical-align: middle; text-align: center; line-height: 1.15; margin: 0 2px; }
.frac > span:first-child { border-bottom: 1.5px solid currentColor; padding: 0 3px 1px; }
.frac > span:last-child { padding: 1px 3px 0; }
.sqrt { border-top: 1.5px solid currentColor; padding: 0 2px; margin-left: 1px; }
.sqrt::before { content: "√"; margin-left: -10px; margin-right: 1px; }
.vec { position: relative; display: inline-block; }
.vec::after { content: "→"; position: absolute; left: 50%; top: -.72em; transform: translateX(-50%) scaleX(1.3); font-size: .7em; line-height: 1; font-family: var(--font-sans); }
sup, sub { font-size: .72em; line-height: 0; }
.key { color: var(--yellow); }
.ok { color: var(--green); } .ko { color: var(--red); } .bl { color: var(--blue); } .vi { color: var(--violet); } .or { color: var(--orange); } .cy { color: var(--cyan); } .pk { color: var(--pink); }
code, .mono { font-family: var(--font-mono); font-size: .9em; background: var(--sunken); border: 1px solid var(--line); border-radius: 6px; padding: 1px 6px; }
pre { font-family: var(--font-mono); font-size: 13.5px; background: var(--sunken); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 12px 14px; overflow: auto; line-height: 1.5; }
pre .c { color: var(--strong); } pre .k { color: var(--violet); } pre .s { color: var(--green); } pre .n { color: var(--orange); }

/* tableaux */
table { border-collapse: separate; border-spacing: 0; width: 100%; margin: 12px 0; font-size: 14.5px; border: 1px solid var(--line); border-radius: var(--r-lg); overflow: hidden; background: var(--sunken); }
th, td { padding: 8px 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
th { background: var(--card); color: var(--fg); font-weight: 700; font-size: 13.5px; }
tr:last-child td { border-bottom: 0; }
td + td, th + th { border-left: 1px solid var(--line); }
.tscroll { overflow-x: auto; }

/* tableau de variations / signes */
table.tv { width: auto; min-width: 380px; text-align: center; }
table.tv th, table.tv td { text-align: center; }
table.tv th:first-child, table.tv td:first-child { text-align: left; background: var(--card); font-family: var(--font-math); font-size: 16px; white-space: nowrap; }
table.tv td { font-family: var(--font-math); font-size: 17px; }
table.tv .arrow { font-size: 26px; color: var(--mat); }
table.tv .zero { color: var(--yellow); }

/* figures */
figure { margin: 12px 0; background: var(--sunken); border: 1px solid var(--line); border-radius: var(--r-xl); padding: 10px; }
figure svg { display: block; width: 100%; height: auto; max-height: 340px; }
figcaption { color: var(--faint); font-size: 13px; text-align: center; margin-top: 4px; }
svg text { font-family: var(--font-sans); }
.plot { max-width: 560px; margin-inline: auto; }

/* exercices */
details.exo { background: var(--card); border: 1px solid var(--line); border-radius: var(--r-xl); margin: 12px 0; overflow: hidden; }
details.exo > summary { cursor: pointer; list-style: none; padding: 12px 16px; display: flex; gap: 10px; align-items: center; font-weight: 650; }
details.exo > summary::-webkit-details-marker { display: none; }
details.exo > summary::before { content: "▸"; color: var(--mat); transition: transform .2s; }
details.exo[open] > summary::before { transform: rotate(90deg); }
details.exo > summary .chip { margin-left: auto; flex: none; }
details.exo > summary > .st { flex: 1; }
details.exo > .exo-body { padding: 4px 18px 16px; border-top: 1px dashed var(--line); }
.enonce { background: var(--sunken); border-radius: var(--r-lg); padding: 10px 14px; margin: 10px 0; border: 1px solid var(--line); }
.sol { border-left: 3px solid var(--green); padding-left: 14px; }

/* quiz flash */
.quiz { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 10px; }
.card-q { perspective: 900px; cursor: pointer; min-height: 112px; }
.card-q .in { position: relative; width: 100%; height: 100%; min-height: 112px; transition: transform .5s; transform-style: preserve-3d; }
.card-q.flip .in { transform: rotateY(180deg); }
.card-q .face { position: absolute; inset: 0; backface-visibility: hidden; border-radius: var(--r-xl); border: 1px solid var(--line); padding: 14px 16px; display: grid; align-content: center; }
.card-q .face > .qt { display: block; }
.card-q .front { background: var(--card); }
.card-q .front::after { display: block; content: "Cliquer pour retourner ↻"; font-size: 11.5px; color: var(--strong); margin-top: 6px; }
.card-q .back { background: color-mix(in srgb, var(--green) 10%, var(--card)); border-color: #4ade8066; transform: rotateY(180deg); }

/* Mode flash : on cache les formules pour s'auto-interroger */
body.flash .fx .f, body.flash .hide-flash { filter: blur(9px); cursor: pointer; user-select: none; }
body.flash .fx .f.shown, body.flash .hide-flash.shown { filter: none; }
.flash-banner { display: none; position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%); z-index: 20; background: var(--card); border: 1px solid var(--mat); color: var(--fg); border-radius: 99px; padding: 8px 18px; font-size: 13.5px; box-shadow: var(--lift); }
body.flash .flash-banner { display: block; }

/* accueil */
.hero { background: var(--raised); border: 1px solid var(--line); border-radius: var(--r-2xl); padding: 34px clamp(18px, 4vw, 46px); box-shadow: var(--lift); margin-bottom: 22px; }
.mat-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 14px; }
.mat-card { display: block; background: var(--raised); border: 1px solid var(--line); border-radius: var(--r-2xl); padding: 20px; color: var(--fg); box-shadow: var(--lift); transition: transform .15s, border-color .15s; }
.mat-card:hover { transform: translateY(-2px); border-color: var(--mat); text-decoration: none; }
.mat-card .ico { width: 46px; height: 46px; border-radius: 14px; display: grid; place-items: center; background: var(--sunken); border: 1px solid color-mix(in srgb, var(--mat) 55%, var(--line)); color: var(--mat); font-size: 22px; font-weight: 800; margin-bottom: 12px; }
.mat-card h3 { margin: 0 0 4px; } .mat-card h3::before { display: none; }
.mat-card ul { color: var(--dim); font-size: 13.5px; padding-left: 18px; }
.mat-card .progress { margin-top: 12px; }

.footer { color: var(--strong); font-size: 12.5px; text-align: center; margin-top: 40px; }
.menu-btn { display: none; }

@media (max-width: 920px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; z-index: 30; inset: 10px auto 10px 10px; width: 290px; height: auto; transform: translateX(-110%); transition: transform .25s; }
  body.menu .side { transform: none; }
  .menu-btn { display: inline-flex; position: fixed; top: 16px; right: 16px; z-index: 31; }
  .fiche-head { flex-wrap: wrap; }
}

/* Impression : version claire pour économiser l'encre */
@media print {
  :root { --backdrop: #fff; --sunken: #f5f7fb; --ground: #fff; --raised: #fff; --card: #fafbfd; --line: #c9d2e0; --fg: #111; --dim: #222; --faint: #555; --strong: #777; }
  .side, .menu-btn, .btn, .flash-banner { display: none !important; }
  .shell { display: block; padding: 0; }
  .main, .fiche { box-shadow: none; border: 0; padding: 0; }
  .fiche { page-break-before: always; }
  details.exo > .exo-body { display: block; }
  .card-q .back { position: static; transform: none; }
  body.flash .fx .f { filter: none; }
}

/* ======================= Onglets de chapitre ======================= */
.tabs { display: flex; flex-wrap: wrap; gap: 6px; margin: 18px 0 6px; padding: 6px; background: var(--sunken); border: 1px solid var(--line); border-radius: var(--r-xl); position: sticky; top: 8px; z-index: 5; box-shadow: 0 8px 20px #0005; }
.tab { display: inline-flex; align-items: center; gap: 7px; padding: 7px 13px; border-radius: var(--r-lg); border: 0; background: transparent; color: var(--dim); font: inherit; font-size: 13.5px; font-weight: 650; cursor: pointer; }
.tab:hover { background: var(--hover); color: var(--fg); }
.tab.on { background: var(--card); color: var(--mat); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--mat) 60%, transparent); }
.tab small { font-size: 11px; padding: 0 6px; border-radius: 99px; background: var(--hover); color: var(--faint); }
.tab.on small { background: color-mix(in srgb, var(--mat) 25%, var(--card)); color: var(--mat); }
.panel { display: none; animation: fadein .2s; }
.panel.on { display: block; }
@keyframes fadein { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.tool-row { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin: 12px 0; }

/* Vocabulaire */
table.voc td:first-child { font-weight: 700; color: var(--mat); font-family: var(--font-math); font-size: 16px; white-space: nowrap; }
table.voc.masked td.vh { filter: blur(7px); cursor: pointer; user-select: none; }
table.voc.masked td.vh.shown { filter: none; }

/* Flashcards */
.deck { max-width: 640px; margin: 10px auto; outline: none; }
.deck-top { display: flex; justify-content: space-between; color: var(--faint); font-size: 13px; font-weight: 650; margin-bottom: 8px; }
.fc { perspective: 1100px; cursor: pointer; height: 220px; }
.fc-in { position: relative; width: 100%; height: 100%; transition: transform .5s; transform-style: preserve-3d; }
.fc.flip .fc-in { transform: rotateY(180deg); }
.fc-face { position: absolute; inset: 0; backface-visibility: hidden; border-radius: var(--r-2xl); border: 1px solid var(--line); display: grid; place-items: center; text-align: center; padding: 22px 26px; font-size: 19px; line-height: 1.45; overflow: auto; }
.fc-front { background: linear-gradient(160deg, var(--card), var(--sunken)); }
.fc-front::before { content: "QUESTION"; position: absolute; top: 12px; left: 16px; font-size: 11px; letter-spacing: .1em; color: var(--mat); font-weight: 800; }
.fc-back { background: color-mix(in srgb, var(--green) 10%, var(--card)); border-color: #4ade8066; transform: rotateY(180deg); }
.fc-back::before { content: "RÉPONSE"; position: absolute; top: 12px; left: 16px; font-size: 11px; letter-spacing: .1em; color: var(--green); font-weight: 800; }
.fc[data-state="ok"] .fc-front { box-shadow: inset 0 0 0 2px #4ade8055; }
.fc[data-state="ko"] .fc-front { box-shadow: inset 0 0 0 2px #f8717155; }
.deck-btns { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 12px; }
.deck-btns .ok { color: var(--green); } .deck-btns .ko { color: var(--orange); }

/* QCM */
.qq { background: var(--card); border: 1px solid var(--line); border-radius: var(--r-xl); padding: 12px 16px; margin: 10px 0; }
.qq .qt { margin: 0 0 8px; }
.qo { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 8px; }
.qopt { text-align: left; padding: 9px 12px; border-radius: var(--r-lg); border: 1px solid var(--line); background: var(--sunken); color: var(--dim); font: inherit; font-size: 14.5px; cursor: pointer; }
.qopt:hover { border-color: var(--mat); color: var(--fg); }
.answered .qopt { cursor: default; opacity: .65; }
.qopt.good { opacity: 1; border-color: var(--green); background: color-mix(in srgb, var(--green) 15%, var(--sunken)); color: var(--fg); }
.qopt.bad { opacity: 1; border-color: var(--red); background: color-mix(in srgb, var(--red) 15%, var(--sunken)); color: var(--fg); }
.qe { font-size: 14px; color: var(--dim); margin-top: 8px; }
.qe:empty { display: none; }

/* Exercices en 6 étapes */
ol.six { list-style: none; padding: 0; margin: 10px 0; display: grid; gap: 8px; }
ol.six > li { background: var(--sunken); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 9px 14px; margin: 0; }
.six-l { display: block; font-size: 12px; font-weight: 800; letter-spacing: .04em; color: var(--mat); text-transform: uppercase; margin-bottom: 2px; }
ol.six > li:last-child { border-color: #4ade8077; background: color-mix(in srgb, var(--green) 8%, var(--sunken)); }
ol.six > li:last-child .six-l { color: var(--green); }

/* Calculatrice */
.calc { position: fixed; right: 18px; bottom: 18px; z-index: 40; width: 330px; background: var(--raised); border: 1px solid var(--line); border-radius: var(--r-2xl); box-shadow: 0 24px 60px #000a; padding: 12px; display: none; }
.calc.open { display: block; }
.calc-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; } .calc-head b { flex: 1; }
.calc-head .btn { padding: 4px 10px; }
.calc-in { width: 100%; padding: 10px 12px; border-radius: var(--r-lg); border: 1px solid var(--line); background: var(--sunken); color: var(--fg); font: 16px var(--font-mono); outline: none; }
.calc-in:focus { border-color: var(--accent); }
.calc-out { text-align: right; font: 700 24px var(--font-mono); color: var(--accent); padding: 8px 4px; min-height: 44px; overflow-x: auto; }
.calc-keys { display: grid; grid-template-columns: repeat(6, 1fr); gap: 5px; }
.calc-keys button { padding: 9px 0; border-radius: 9px; border: 1px solid var(--line); background: var(--card); color: var(--fg); font: 600 13px var(--font-sans); cursor: pointer; }
.calc-keys button:hover { background: var(--hover); }
.calc-keys [data-k="="] { background: var(--accent); color: #10131a; border-color: var(--accent); }
.calc-keys [data-k="C"] { color: var(--red); }
.calc-hist { margin-top: 8px; line-height: 1.5; }

/* Pages littéraires */
blockquote { margin: 10px 0; padding: 10px 16px; border-left: 4px solid var(--mat); background: var(--card); border-radius: 0 var(--r-lg) var(--r-lg) 0; color: var(--dim); font-style: italic; }
blockquote cite { display: block; font-style: normal; font-size: 13px; color: var(--faint); margin-top: 4px; }
.timeline { position: relative; margin: 14px 0; padding-left: 26px; }
.timeline::before { content: ""; position: absolute; left: 8px; top: 4px; bottom: 4px; width: 3px; border-radius: 3px; background: linear-gradient(var(--mat), transparent); }
.timeline > div { position: relative; margin: 0 0 10px; }
.timeline > div::before { content: ""; position: absolute; left: -24px; top: 6px; width: 11px; height: 11px; border-radius: 50%; background: var(--mat); box-shadow: 0 0 0 4px var(--ground); }
.timeline b.d { color: var(--mat); font-family: var(--font-mono); margin-right: 8px; }
[data-mat="philo"] { --mat: var(--pink); }
[data-mat="hg"] { --mat: var(--yellow); }
[data-mat="ang"] { --mat: var(--red); }

@media print {
  .tabs, .deck-btns, .calc, .tool-row .btn { display: none !important; }
  .panel { display: block !important; }
  .panel::before { content: attr(data-name); display: block; font-weight: 800; margin: 14px 0 6px; text-transform: uppercase; font-size: 12px; }
  .fc { height: auto; } .fc-in { transform: none !important; } .fc-face { position: static; transform: none; margin-bottom: 6px; }
}

/* ======================= V2 — design « Abysse+ » ======================= */
body { background:
  radial-gradient(1200px 600px at 85% -10%, #1d3a6a44, transparent 60%),
  radial-gradient(900px 500px at -10% 110%, #3b1d6a33, transparent 60%), var(--backdrop); background-attachment: fixed; }
.main { background: linear-gradient(180deg, #171a22ee, #14161ccc); backdrop-filter: blur(6px); }
.side { background: linear-gradient(180deg, #1c2029, #181b22); }
.fiche { background: linear-gradient(180deg, #1d212b, #1a1d25); position: relative; }
.fiche::before { content: ""; position: absolute; left: 24px; right: 24px; top: 0; height: 2px; background: linear-gradient(90deg, transparent, var(--mat), transparent); opacity: .6; }
.fiche:hover { border-color: color-mix(in srgb, var(--mat) 35%, var(--line)); }
.reveal { opacity: 0; transform: translateY(14px); transition: opacity .6s ease, transform .6s ease; }
.reveal.in { opacity: 1; transform: none; }
.fiche-num { box-shadow: 0 0 0 4px color-mix(in srgb, var(--mat) 10%, transparent), 0 8px 24px #0006; background: radial-gradient(circle at 30% 25%, color-mix(in srgb, var(--mat) 25%, var(--sunken)), var(--sunken)); }
h1 { background: linear-gradient(90deg, var(--fg), color-mix(in srgb, var(--mat) 70%, var(--fg))); -webkit-background-clip: text; background-clip: text; color: transparent; }

/* barre supérieure */
.topbar { position: sticky; top: 0; z-index: 25; display: flex; align-items: center; gap: 10px; margin: -28px calc(-1 * clamp(16px, 4vw, 54px)) 22px; padding: 12px clamp(16px, 4vw, 54px); background: #15171dd9; backdrop-filter: blur(14px) saturate(140%); border-bottom: 1px solid #ffffff10; border-radius: var(--r-2xl) var(--r-2xl) 0 0; }
.crumb { display: flex; align-items: center; gap: 8px; font-size: 13.5px; color: var(--faint); min-width: 0; }
.crumb a { color: var(--dim); } .crumb b { color: var(--fg); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top-search { margin-left: auto; display: flex; align-items: center; gap: 10px; min-width: 260px; padding: 8px 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--sunken); color: var(--faint); font: inherit; font-size: 13.5px; cursor: pointer; }
.top-search:hover { border-color: var(--accent); color: var(--fg); }
.top-search kbd, .kbd { margin-left: auto; font: 600 11px var(--font-mono); padding: 2px 6px; border-radius: 6px; border: 1px solid var(--line); background: var(--card); color: var(--dim); }
.top-hub { display: inline-flex; align-items: center; gap: 6px; padding: 8px 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--card); color: var(--fg); font-weight: 650; font-size: 13.5px; }
.top-hub:hover { text-decoration: none; border-color: var(--accent); }

/* palette de recherche */
.palette { position: fixed; inset: 0; z-index: 60; display: none; place-items: start center; padding-top: 10vh; background: #05060acc; backdrop-filter: blur(6px); }
.palette.open { display: grid; }
.pal-box { width: min(720px, 92vw); background: var(--raised); border: 1px solid var(--line); border-radius: 20px; box-shadow: 0 30px 80px #000c; overflow: hidden; }
.pal-box input { width: 100%; padding: 18px 20px; border: 0; border-bottom: 1px solid var(--line); background: transparent; color: var(--fg); font: 500 17px var(--font-sans); outline: none; }
.pal-res { max-height: 56vh; overflow: auto; padding: 8px; }
.pal-res a { display: flex; gap: 12px; align-items: center; padding: 10px 12px; border-radius: 12px; color: var(--dim); }
.pal-res a:hover, .pal-res a.sel { background: var(--hover); color: var(--fg); text-decoration: none; }
.pal-res .num { flex: none; min-width: 42px; height: 26px; padding: 0 6px; border-radius: 8px; display: grid; place-items: center; font: 800 11.5px var(--font-sans); color: #10131a; }
.pal-res small { display: block; color: var(--faint); font-size: 12px; }
.pal-empty { padding: 18px; color: var(--faint); }
.pal-foot { display: flex; gap: 14px; padding: 10px 16px; border-top: 1px solid var(--line); color: var(--strong); font-size: 12px; }

/* Labo */
.viz-card { background: linear-gradient(180deg, #151821, #12141b); border: 1px solid color-mix(in srgb, var(--mat) 35%, var(--line)); border-radius: var(--r-2xl); padding: 16px 18px; margin: 14px 0; box-shadow: inset 0 1px 0 #ffffff0d, 0 18px 40px #0005; }
.viz-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 10px; margin-bottom: 10px; }
.viz-head b { font-size: 16px; } .viz-head small { flex-basis: 100%; color: var(--faint); font-size: 13px; }
.viz-badge { font-size: 11px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: #10131a; background: var(--mat); padding: 3px 9px; border-radius: 99px; }
.viz-stage { border-radius: var(--r-lg); background: #0f1117; border: 1px solid #ffffff0d; overflow: hidden; position: relative; }
.viz-stage canvas, .viz-svg { display: block; width: 100%; }
.viz-svg { height: auto; max-height: 340px; }
.viz-ctrl { display: flex; flex-wrap: wrap; gap: 10px 18px; align-items: center; margin-top: 12px; }
.viz-sl { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--dim); background: var(--sunken); border: 1px solid var(--line); border-radius: 12px; padding: 6px 12px; }
.viz-sl input { accent-color: var(--mat); width: 140px; }
.viz-sl output { font: 700 12.5px var(--font-mono); color: var(--fg); min-width: 64px; }
.viz-btn { padding: 7px 12px; font-size: 13px; }
.viz-out { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.viz-ro { background: var(--sunken); border: 1px solid var(--line); border-radius: 12px; padding: 6px 12px; display: flex; flex-direction: column; }
.viz-ro small { color: var(--faint); font-size: 11.5px; } .viz-ro b { font: 700 14.5px var(--font-mono); }
.viz-pascal { padding: 16px; text-align: center; font: 700 15px var(--font-mono); }
.viz-pascal div { display: flex; justify-content: center; gap: 6px; margin: 4px 0; }
.viz-pascal span { min-width: 38px; padding: 4px 6px; border-radius: 8px; background: var(--card); color: var(--dim); }
.viz-pascal span.on { background: var(--yellow); color: #10131a; } .viz-pascal span.par { background: #a78bfa55; color: var(--fg); }
.viz-bits { display: flex; justify-content: center; gap: 8px; padding: 22px; flex-wrap: wrap; }
.bit { width: 56px; height: 70px; border-radius: 14px; border: 1px solid var(--line); background: var(--card); color: var(--dim); font: 800 24px var(--font-mono); cursor: pointer; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; }
.bit small { font: 600 11px var(--font-sans); color: var(--strong); }
.bit.on { background: color-mix(in srgb, var(--cyan) 22%, var(--card)); color: var(--cyan); border-color: var(--cyan); box-shadow: 0 0 18px #22d3ee44; }
.viz-led { display: flex; gap: 22px; align-items: center; padding: 22px; flex-wrap: wrap; }
.led-bulb { width: 90px; height: 90px; border-radius: 50%; transition: all .3s; flex: none; }
.led-info { font-size: 15px; line-height: 1.8; color: var(--dim); }
.viz-ip { padding: 16px; display: grid; gap: 12px; }
.viz-ip input { max-width: 260px; font-family: var(--font-mono); }
.ipbits div { font: 600 13px var(--font-mono); display: flex; flex-wrap: wrap; align-items: center; gap: 1px; margin: 4px 0; }
.ipbits small { width: 64px; color: var(--faint); font-family: var(--font-sans); }
.ipbits span { padding: 2px 3px; border-radius: 4px; } .ipbits span.n { background: #22d3ee33; color: var(--cyan); } .ipbits span.h { background: #f472b622; color: var(--pink); }
.ipbits i { color: var(--strong); padding: 0 3px; }

/* hub */
.hub-hero { position: relative; overflow: hidden; background: linear-gradient(135deg, #1f2a44, #1b1e26 55%, #2a1f44); border: 1px solid var(--line); border-radius: 26px; padding: 36px clamp(20px, 4vw, 48px); box-shadow: var(--lift); margin-bottom: 18px; }
.hub-hero h1 { font-size: clamp(30px, 4.6vw, 48px); margin: 8px 0 10px; max-width: 640px; }
.hub-hero .lead { font-size: 16px; max-width: 620px; position: relative; }
.hero-art { position: absolute; right: -30px; top: -20px; width: 480px; max-width: 52%; opacity: .95; pointer-events: none; }
.hub-grid { display: grid; grid-template-columns: repeat(12, 1fr); gap: 14px; margin-bottom: 18px; }
.panel-card { grid-column: span 4; background: linear-gradient(180deg, #1d212b, #1a1d25); border: 1px solid var(--line); border-radius: 20px; padding: 18px 20px; box-shadow: var(--lift); }
.panel-card.w6 { grid-column: span 6; } .panel-card.w8 { grid-column: span 8; } .panel-card.w12 { grid-column: span 12; }
.panel-card h3 { margin-top: 0; }
.stat-big { font: 800 40px var(--font-sans); letter-spacing: -.02em; }
.stat-sub { color: var(--faint); font-size: 13px; }
.stats-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.stats-row > div { background: var(--sunken); border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; }
.count-row { display: grid; gap: 10px; }
.count { display: flex; align-items: center; gap: 12px; background: var(--sunken); border: 1px solid var(--line); border-radius: 14px; padding: 10px 14px; }
.count b { font: 800 22px var(--font-mono); color: var(--accent); min-width: 70px; } .count span { color: var(--dim); font-size: 13.5px; }
.today a { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 12px; background: var(--sunken); border: 1px solid var(--line); margin: 8px 0; color: var(--dim); }
.today a:hover { border-color: var(--accent); text-decoration: none; color: var(--fg); }
.today .num { min-width: 38px; height: 24px; border-radius: 7px; display: grid; place-items: center; font: 800 11px var(--font-sans); color: #10131a; padding: 0 6px; }
.ring { --p: 0; width: 64px; height: 64px; border-radius: 50%; display: grid; place-items: center; background: conic-gradient(var(--mat) calc(var(--p) * 1%), #2e3442 0); flex: none; }
.ring span { width: 50px; height: 50px; border-radius: 50%; background: #1b1e26; display: grid; place-items: center; font: 800 13px var(--font-sans); color: var(--fg); }
.mat-card .mc-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.labo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; }
.labo-grid a { display: flex; gap: 10px; align-items: center; padding: 12px; border-radius: 14px; background: var(--sunken); border: 1px solid var(--line); color: var(--dim); font-size: 13.5px; transition: transform .15s, border-color .15s; }
.labo-grid a:hover { border-color: var(--mat); color: var(--fg); text-decoration: none; transform: translateY(-2px); }
.labo-grid i { font-style: normal; font-size: 20px; }
.labo-grid small { display: block; color: var(--faint); font-size: 11.5px; }
.news { border-left: 4px solid var(--yellow); }
@media (max-width: 1100px) { .panel-card, .panel-card.w6, .panel-card.w8 { grid-column: span 12; } .hero-art { opacity: .2; } }
@media (max-width: 920px) { .top-search { min-width: 0; } .top-search span { display: none; } }
@media print { .topbar, .palette, .viz-ctrl { display: none !important; } .reveal { opacity: 1; transform: none; } }
