/* TRUforma — charte TRUvector : sombre cyberpunk, Orbitron + Share Tech Mono, cyan / violet / or */
:root {
  --bg: #05070d; --panel: #0b1020; --panel2: #0f1630; --line: #1c2a4a; --line2: #2a3d66;
  --cyan: #00e5ff; --purple: #b04dff; --gold: #ffc940; --red: #ff3b6b; --green: #4dffa6;
  --text: #cfe6f2; --dim: #7b8fa8;
  --radius: 0;
  --head: 'Orbitron', sans-serif; --mono: 'Share Tech Mono', ui-monospace, monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg); color: var(--text); font-family: var(--mono); font-size: 15px; line-height: 1.5;
  background-image: linear-gradient(rgba(0, 229, 255, .035) 1px, transparent 1px), linear-gradient(90deg, rgba(0, 229, 255, .035) 1px, transparent 1px);
  background-size: 32px 32px; display: flex; flex-direction: column; height: 100vh; overflow: hidden;
}
h1, h2, h3, h4 { font-family: var(--head); letter-spacing: .05em; margin: 0 0 .5em; }
a { color: var(--cyan); }
button, select, input, textarea { font-family: var(--mono); font-size: 14px; }

/* ---------- En-tête ---------- */
.topbar { display: flex; align-items: center; gap: 18px; padding: 10px 18px; border-bottom: 1px solid var(--line); background: rgba(5, 7, 13, .92); position: sticky; top: 0; z-index: 20; flex-wrap: wrap; }
.logo { display: flex; align-items: center; gap: 10px; text-decoration: none; }
.logo svg { width: 34px; height: 34px; }
.logo b { font-family: var(--head); font-weight: 900; font-size: 20px; background: linear-gradient(90deg, var(--cyan), var(--purple), var(--gold)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.logo small { display: block; font-size: 10px; letter-spacing: .3em; color: var(--dim); }
nav.tabs { display: flex; gap: 4px; flex-wrap: wrap; flex: 1; }
nav.tabs a { color: var(--dim); text-decoration: none; padding: 7px 12px; border: 1px solid transparent; font-family: var(--head); font-size: 12px; letter-spacing: .08em; }
nav.tabs a:hover { color: var(--text); border-color: var(--line); }
nav.tabs a.active { color: var(--cyan); border-color: var(--cyan); box-shadow: 0 0 12px rgba(0, 229, 255, .25) inset; }

main { flex: 1; min-height: 0; overflow: auto; }
.view { display: none; height: 100%; }
.view.active { display: block; }
.wrap { max-width: 1200px; margin: 0 auto; padding: 22px 18px 60px; }

/* ---------- Éléments ---------- */
.btn { background: transparent; color: var(--cyan); border: 1px solid var(--cyan); padding: 7px 13px; cursor: pointer; letter-spacing: .03em; transition: background .15s, box-shadow .15s; }
.btn:hover { background: rgba(0, 229, 255, .1); box-shadow: 0 0 10px rgba(0, 229, 255, .25); }
.btn:disabled { opacity: .35; cursor: not-allowed; box-shadow: none; }
.btn.gold { color: var(--gold); border-color: var(--gold); }
.btn.purple { color: var(--purple); border-color: var(--purple); }
.btn.red { color: var(--red); border-color: var(--red); }
.btn.solid { background: var(--cyan); color: #001018; }
.btn.on { background: rgba(0, 229, 255, .2); color: #fff; }
.btn.icon { padding: 6px 10px; min-width: 38px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.grow { flex: 1; }
.dim { color: var(--dim); }
.chip { border: 1px solid var(--line2); color: var(--dim); background: transparent; padding: 4px 10px; cursor: pointer; font-size: 12px; }
.chip.on { color: var(--cyan); border-color: var(--cyan); }
input[type=text], input[type=search], input[type=url], input[type=number], select, textarea { background: var(--panel2); color: var(--text); border: 1px solid var(--line2); padding: 7px 9px; }
input[type=range] { accent-color: var(--cyan); }
.panel { background: var(--panel); border: 1px solid var(--line); padding: 14px; }
.cut { clip-path: polygon(0 0, calc(100% - 14px) 0, 100% 14px, 100% 100%, 0 100%); }
.label { font-family: var(--head); font-size: 10px; letter-spacing: .18em; color: var(--dim); text-transform: uppercase; margin-bottom: 6px; }
.badge { display: inline-block; font-size: 11px; padding: 1px 7px; border: 1px solid currentColor; }
.stars { color: var(--gold); letter-spacing: 2px; }
hr { border: 0; border-top: 1px solid var(--line); margin: 14px 0; }
kbd { border: 1px solid var(--line2); padding: 0 5px; font-size: 12px; }

/* ---------- Bibliothèque ---------- */
.hero { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; flex-wrap: wrap; margin-bottom: 18px; }
.hero h1 { font-size: clamp(24px, 4vw, 38px); margin: 0; }
.hero p { margin: 4px 0 0; color: var(--dim); }
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 18px; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }
.card { background: var(--panel); border: 1px solid var(--line); cursor: pointer; display: flex; flex-direction: column; transition: border-color .15s, transform .15s; position: relative; }
.card:hover { border-color: var(--cyan); transform: translateY(-2px); }
.card .thumb { height: 210px; display: grid; place-items: center; background: radial-gradient(circle at 50% 40%, #12204a, #070b16 70%); border-bottom: 1px solid var(--line); }
.card .thumb svg { width: 86%; height: 86%; }
.card .info { padding: 10px 12px; }
.card h3 { font-size: 14px; margin: 0 0 4px; color: #fff; }
.card .meta { display: flex; justify-content: space-between; font-size: 12px; color: var(--dim); }
.card .fav { position: absolute; top: 6px; right: 8px; background: none; border: 0; color: var(--dim); font-size: 20px; cursor: pointer; }
.card .fav.on { color: var(--gold); }
.card .done { position: absolute; top: 8px; left: 8px; color: var(--green); font-size: 12px; border: 1px solid var(--green); padding: 0 6px; background: rgba(0, 0, 0, .5); }
.progress { height: 3px; background: var(--line); }
.progress i { display: block; height: 100%; background: linear-gradient(90deg, var(--cyan), var(--purple)); }
.section-title { margin: 30px 0 12px; font-size: 16px; color: var(--purple); display: flex; gap: 10px; align-items: center; }
.section-title::after { content: ""; flex: 1; height: 1px; background: linear-gradient(90deg, var(--purple), transparent); }

/* ---------- Pliage guidé ---------- */
.guided { display: grid; grid-template-columns: 1fr 380px; height: 100%; }
.stage { position: relative; min-height: 320px; background: radial-gradient(ellipse at 50% 30%, #101c40 0%, #05070d 70%); }
.stage canvas { display: block; width: 100%; height: 100%; }
.stage .overlay { position: absolute; left: 12px; top: 10px; right: 12px; display: flex; justify-content: space-between; pointer-events: none; }
.stage .overlay > * { pointer-events: auto; }
.stage .title { font-family: var(--head); font-size: 15px; }
.side { border-left: 1px solid var(--line); background: var(--panel); display: flex; flex-direction: column; min-height: 0; overflow: auto; }
.side .block { padding: 14px; border-bottom: 1px solid var(--line); }
.stepnum { font-family: var(--head); font-size: 28px; color: var(--cyan); }
.stepnum small { font-size: 14px; color: var(--dim); }
.caption { font-size: 17px; color: #fff; min-height: 3.2em; }
.diagram { background: #060a14; border: 1px solid var(--line); aspect-ratio: 1.25; display: grid; place-items: center; }
.diagram svg { width: 100%; height: 100%; }
.controls { display: flex; gap: 6px; flex-wrap: wrap; }
.legend { font-size: 12px; color: var(--dim); display: grid; grid-template-columns: auto 1fr; gap: 4px 10px; align-items: center; }
.legend svg { width: 46px; height: 10px; }
.steplist { list-style: none; margin: 0; padding: 0; font-size: 13px; max-height: 34vh; overflow: auto; position: relative; }
.steplist li { padding: 5px 8px; cursor: pointer; border-left: 2px solid transparent; color: var(--dim); }
.steplist li:hover { color: var(--text); }
.steplist li.cur { border-left-color: var(--cyan); color: #fff; background: rgba(0, 229, 255, .06); }
.steplist li.past { color: #8fb3c9; }
.handsfree .side { font-size: 18px; }
.handsfree .caption { font-size: 24px; }
.handsfree .btn { padding: 12px 18px; font-size: 18px; }

/* ---------- Studio ---------- */
.studio { display: grid; grid-template-columns: 220px 1fr 1fr; height: 100%; }
.tools { border-right: 1px solid var(--line); background: var(--panel); padding: 10px; overflow: auto; display: flex; flex-direction: column; gap: 12px; }
.tools .btn { width: 100%; text-align: left; }
.tools .grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.tools .grid2 .btn { text-align: center; min-width: 0; padding-left: 4px; padding-right: 4px; overflow: hidden; text-overflow: ellipsis; }
#st-types { grid-template-columns: 1fr; }
.editor { position: relative; display: flex; flex-direction: column; min-height: 0; border-right: 1px solid var(--line); }
.editor svg.cp { flex: 1; width: 100%; min-height: 0; touch-action: none; cursor: crosshair; background: #060a14; }
.editor .status { padding: 6px 10px; font-size: 12px; color: var(--dim); border-top: 1px solid var(--line); display: flex; gap: 12px; flex-wrap: wrap; }
.simpane { display: flex; flex-direction: column; min-height: 0; }
.simpane .stage { flex: 1; }
.simbar { padding: 10px; border-top: 1px solid var(--line); background: var(--panel); display: flex; flex-direction: column; gap: 8px; }
.tabsmall { display: flex; border-bottom: 1px solid var(--line); }
.tabsmall button { flex: 1; background: none; border: 0; border-bottom: 2px solid transparent; color: var(--dim); padding: 9px; cursor: pointer; font-family: var(--head); font-size: 11px; letter-spacing: .1em; }
.tabsmall button.on { color: var(--cyan); border-bottom-color: var(--cyan); }
.pane { display: none; flex: 1; min-height: 0; overflow: auto; }
.pane.on { display: flex; flex-direction: column; }
.checks { font-size: 13px; padding: 10px; }
.checks .ok { color: var(--green); }
.checks .ko { color: var(--red); }
.checks li { margin: 3px 0; cursor: pointer; }
.diaglist { list-style: none; margin: 0; padding: 10px; display: flex; flex-direction: column; gap: 8px; }
.diaglist li { display: grid; grid-template-columns: 90px 1fr auto; gap: 8px; align-items: start; background: var(--panel2); border: 1px solid var(--line); padding: 6px; }
.diaglist li svg { width: 90px; height: 90px; }
.diaglist textarea { width: 100%; min-height: 60px; resize: vertical; }
.diaglist .ord { display: flex; flex-direction: column; gap: 4px; }

/* ---------- Impression ---------- */
.printgrid { display: grid; grid-template-columns: 320px 1fr; gap: 18px; }
.sheet { background: #fff; padding: 10px; border: 1px solid var(--line); max-height: 78vh; overflow: auto; }
.sheet svg { width: 100%; height: auto; display: block; }

/* ---------- Divers ---------- */
.toast { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); background: var(--panel2); border: 1px solid var(--cyan); color: #fff; padding: 9px 16px; z-index: 100; opacity: 0; transition: opacity .25s; pointer-events: none; max-width: 90vw; }
.toast.show { opacity: 1; }
.modal { position: fixed; inset: 0; background: rgba(0, 0, 0, .7); display: none; place-items: center; z-index: 50; }
.modal.show { display: grid; }
.modal .panel { max-width: 520px; width: 92vw; }
footer.foot { text-align: center; font-size: 11px; color: var(--dim); padding: 8px; border-top: 1px solid var(--line); }
.about-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 14px; }

@media (max-width: 980px) {
  body { height: auto; overflow: auto; }
  .topbar { gap: 8px; padding: 8px 10px; }
  nav.tabs { flex-wrap: nowrap; overflow-x: auto; }
  nav.tabs a { padding: 6px 8px; font-size: 11px; white-space: nowrap; }
  main { overflow: visible; }
  .guided { grid-template-columns: 1fr; height: auto; }
  .guided .stage { height: 55vh; }
  .side { border-left: 0; border-top: 1px solid var(--line); }
  .studio { grid-template-columns: 1fr; height: auto; }
  .steplist { max-height: none; }
  .tools { flex-direction: row; flex-wrap: wrap; border-right: 0; border-bottom: 1px solid var(--line); }
  .tools > div { min-width: 200px; flex: 1; }
  .editor svg.cp { height: 70vw; flex: none; }
  .simpane .stage { height: 60vw; flex: none; }
  .printgrid { grid-template-columns: 1fr; }
}

@media print {
  body { background: #fff !important; }
  body > *:not(#print-area) { display: none !important; }
  #print-area { display: block !important; }
  #print-area svg { width: 100%; height: auto; }
}
#print-area { display: none; }

/* ---------- Ateliers (phases 3 à 9) ---------- */
.labgrid { display: grid; grid-template-columns: 330px 1fr; gap: 16px; align-items: start; }
.atelier { display: grid; grid-template-columns: 250px 1fr 300px; height: 100%; }
.atelier-main { display: flex; flex-direction: column; min-height: 0; border-right: 1px solid var(--line); }
.sheet-dark { flex: 1; overflow: auto; background: #060a14; padding: 12px; }
.sheet-dark svg { width: 100%; height: auto; min-height: 60vh; }
.pro { font-family: var(--head); font-size: 9px; letter-spacing: .1em; color: #001018; background: var(--gold); padding: 1px 5px; margin-left: 4px; vertical-align: middle; }
body.is-pro .pro { background: var(--green); }
.stage.ar { background: #000; }
.stage.ar canvas { background: transparent; }
#lab-vol, #lab-modulaires, #em-croix, #em-points, #em-machine { overflow: visible; }
.chip input { accent-color: var(--cyan); }
.steplist li.cur { cursor: default; }
#pj-list li { cursor: pointer; }

/* ---------- Mode famille / école ---------- */
body.family nav.tabs a[data-view="studio"], body.family nav.tabs a[data-view="couture"], body.family nav.tabs a[data-view="projets"] { display: none; }
body.family .family-hide { display: none !important; }
body.family .btn, body.family .chip { font-size: 16px; padding: 10px 16px; }
body.family .card h3 { font-size: 17px; }
body.family .caption { font-size: 21px; }

@media (max-width: 980px) {
  .labgrid { grid-template-columns: 1fr; }
  .atelier { grid-template-columns: 1fr; height: auto; }
  .atelier-main { border-right: 0; }
  .sheet-dark svg { min-height: 0; }
}

input[type=color] { background: var(--panel2); border: 1px solid var(--line2); width: 38px; height: 28px; padding: 1px; }
input[type=file] { color: var(--dim); max-width: 100%; }
.brpane select, .labgrid select { max-width: 100%; }
#ga-cards > p, #lib-cards > p { grid-column: 1 / -1; }
