:root {
  --bg: #f7f7f5;
  --surface: #ffffff;
  --surface-2: #f0f0ed;
  --border: #e3e3de;
  --text: #17171a;
  --muted: #62626b;
  --faint: #9a9aa3;
  --accent: #3b82f6;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(0, 0, 0, .04), 0 4px 16px rgba(0, 0, 0, .04);
  --font: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --display: "Space Grotesk", var(--font);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e0f13;
    --surface: #16171d;
    --surface-2: #1d1f26;
    --border: #2a2c35;
    --text: #ececf1;
    --muted: #a1a1ad;
    --faint: #6b6b78;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3);
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #0e0f13;
  --surface: #16171d;
  --surface-2: #1d1f26;
  --border: #2a2c35;
  --text: #ececf1;
  --muted: #a1a1ad;
  --faint: #6b6b78;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3);
  color-scheme: dark;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.6 var(--font);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a { color: inherit; text-decoration: none; }
h1, h2, h3 { font-family: var(--display); line-height: 1.15; margin: 0; letter-spacing: -.01em; }
svg { width: 1em; height: 1em; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }

.wrap { width: 100%; max-width: 1180px; margin: 0 auto; padding: 0 16px; }
@media (min-width: 720px) { .wrap { padding: 0 28px; } }

/* ---------- Topbar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.topbar-inner { display: flex; align-items: center; justify-content: space-between; height: 60px; }
.brand { display: flex; align-items: center; gap: 10px; font-family: var(--display); font-weight: 700; font-size: 19px; }
.brand-accent { color: #3b82f6; margin-left: 2px; }
.brand-mark {
  display: grid; place-items: center; width: 32px; height: 32px; border-radius: 9px;
  background: #3b82f6; color: #fff; font-size: 18px;
}
.icon-btn {
  display: grid; place-items: center; width: 38px; height: 38px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  cursor: pointer; font-size: 18px;
}
.icon-btn:hover { background: var(--surface-2); }
.i-moon { display: none; }
:root[data-theme="dark"] .i-sun { display: none; }
:root[data-theme="dark"] .i-moon { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .i-sun { display: none; }
  :root:not([data-theme="light"]) .i-moon { display: block; }
}

main { flex: 1; padding-bottom: 64px; }

.footer { border-top: 1px solid var(--border); color: var(--faint); font-size: 13px; padding: 22px 0; }

/* ---------- Hero ---------- */
.hero { padding: 56px 0 28px; }
.hero h1 { font-size: clamp(32px, 6vw, 54px); max-width: 16ch; }
.hero h1 em { font-style: normal; color: #3b82f6; }
.hero p { color: var(--muted); font-size: 17px; max-width: 60ch; margin: 16px 0 28px; }

.search {
  display: flex; align-items: center; gap: 10px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  padding: 0 14px; max-width: 560px; box-shadow: var(--shadow);
}
.search:focus-within { border-color: #3b82f6; }
.search svg { color: var(--faint); font-size: 18px; flex: none; }
.search input {
  flex: 1; min-width: 0; border: 0; background: none; color: var(--text);
  font: inherit; font-size: 16px; padding: 14px 0; outline: none;
}
.search kbd {
  font: 12px var(--font); color: var(--faint); border: 1px solid var(--border);
  border-radius: 6px; padding: 1px 6px;
}

.stats { display: flex; flex-wrap: wrap; gap: 24px; margin-top: 26px; color: var(--muted); font-size: 14px; }
.stats b { font-family: var(--display); font-size: 22px; color: var(--text); margin-right: 6px; }

/* ---------- Chips ---------- */
.chips {
  display: flex; gap: 8px; overflow-x: auto; padding: 4px 0 14px; margin: 12px 0 8px;
  scrollbar-width: none;
}
.chips::-webkit-scrollbar { display: none; }
@media (min-width: 720px) { .chips { flex-wrap: wrap; overflow: visible; } }
.chip {
  flex: none; display: inline-flex; align-items: center; gap: 8px;
  border: 1px solid var(--border); background: var(--surface); color: var(--muted);
  border-radius: 999px; padding: 7px 14px; font: 500 14px var(--font); cursor: pointer;
}
.chip:hover { color: var(--text); }
.chip .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--c, var(--faint)); }
.chip[aria-pressed="true"] { background: var(--text); color: var(--bg); border-color: var(--text); }

/* ---------- Domain sections ---------- */
.domain { padding-top: 36px; scroll-margin-top: 70px; }
.domain-head { display: flex; align-items: flex-start; gap: 14px; margin-bottom: 18px; }
.domain-icon {
  flex: none; display: grid; place-items: center; width: 44px; height: 44px; border-radius: 12px;
  background: color-mix(in srgb, var(--c) 14%, transparent); color: var(--c); font-size: 22px;
}
.domain-head h2 { font-size: 24px; display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.domain-head h2 small { font: 500 13px var(--font); color: var(--faint); }
.domain-head p { margin: 4px 0 0; color: var(--muted); font-size: 14px; }

.grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }

.card {
  position: relative; display: flex; flex-direction: column; gap: 10px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px; box-shadow: var(--shadow);
  transition: transform .15s ease, border-color .15s ease;
}
.card::before {
  content: ""; position: absolute; left: 18px; right: 18px; top: 0; height: 3px;
  border-radius: 0 0 3px 3px; background: var(--c); opacity: .9;
}
.card:hover { transform: translateY(-2px); border-color: color-mix(in srgb, var(--c) 50%, var(--border)); }
.card h3 { font-size: 18px; }
.card p { margin: 0; color: var(--muted); font-size: 14px; flex: 1; }
.card-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: 13px; color: var(--faint); }
.level { font-size: 12px; font-weight: 600; color: var(--c); text-transform: uppercase; letter-spacing: .04em; }

.bar { height: 6px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.bar > i { display: block; height: 100%; width: 0; background: var(--c, var(--accent)); border-radius: inherit; transition: width .3s ease; }
.card .bar { flex: 1; max-width: 90px; }

.empty { text-align: center; color: var(--muted); padding: 60px 0; }

/* ---------- Job page ---------- */
.crumbs { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 14px; color: var(--muted); padding: 28px 0 0; }
.crumbs a:hover { color: var(--text); }
.crumbs svg { color: var(--faint); }

.job-head { padding: 22px 0 30px; border-bottom: 1px solid var(--border); margin-bottom: 36px; }
.pill {
  display: inline-flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600;
  color: var(--c); background: color-mix(in srgb, var(--c) 12%, transparent);
  padding: 5px 12px; border-radius: 999px;
}
.job-head h1 { font-size: clamp(30px, 5vw, 46px); margin: 14px 0 10px; }
.job-head > p { color: var(--muted); font-size: 17px; max-width: 65ch; margin: 0 0 24px; }

.meta { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.meta > div { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px; }
.meta dt { font-size: 12px; color: var(--faint); text-transform: uppercase; letter-spacing: .05em; font-weight: 600; }
.meta dd { margin: 4px 0 0; font-weight: 600; }
.meta .progress-line { display: flex; align-items: center; gap: 10px; }
.meta .bar { flex: 1; }
.link-btn { background: none; border: 0; padding: 0; margin-top: 6px; color: var(--faint); font: 13px var(--font); cursor: pointer; text-decoration: underline; }
.link-btn:hover { color: var(--text); }

.layout { display: grid; gap: 36px; }
@media (min-width: 960px) { .layout { grid-template-columns: minmax(0, 1fr) 320px; align-items: start; } }

.legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 13px; color: var(--muted); margin-bottom: 20px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }

/* Timeline */
.timeline { list-style: none; margin: 0; padding: 0; position: relative; }
.step { position: relative; padding-left: 58px; padding-bottom: 26px; }
.step::before {
  content: ""; position: absolute; left: 19px; top: 40px; bottom: -2px; width: 2px;
  background: var(--border);
}
.step:last-child::before { display: none; }
.step.done::before { background: var(--c); }
.node {
  position: absolute; left: 0; top: 0; width: 40px; height: 40px; border-radius: 50%;
  display: grid; place-items: center; font: 700 15px var(--display);
  background: var(--surface); border: 2px solid var(--border); color: var(--muted);
  transition: all .2s ease;
}
.step.started .node { border-color: var(--c); color: var(--c); }
.step.done .node { background: var(--c); border-color: var(--c); color: #fff; }

.step-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow); }
.step-top { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.step-card h3 { font-size: 19px; }
.step-count { font-size: 13px; color: var(--faint); white-space: nowrap; }
.step-card > p { margin: 4px 0 14px; color: var(--muted); font-size: 14px; }

.checklist { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.check {
  display: flex; align-items: flex-start; gap: 12px; padding: 8px 10px; margin: 0 -10px;
  border-radius: 9px; cursor: pointer;
}
.check:hover { background: var(--surface-2); }
.check input { position: absolute; opacity: 0; pointer-events: none; }
.box {
  flex: none; width: 20px; height: 20px; margin-top: 2px; border-radius: 6px;
  border: 2px solid var(--border); display: grid; place-items: center; color: #fff; font-size: 13px;
  transition: all .15s ease;
}
.box svg { stroke-width: 3.5; opacity: 0; }
.check input:checked + .box { background: var(--c); border-color: var(--c); }
.check input:checked + .box svg { opacity: 1; }
.check input:focus-visible + .box { outline: 2px solid var(--c); outline-offset: 2px; }
.check input:checked ~ .label { color: var(--faint); text-decoration: line-through; text-decoration-color: var(--faint); }
.label { flex: 1; }
.opt {
  display: inline-block; font-size: 11px; font-weight: 600; letter-spacing: .03em; text-transform: uppercase;
  color: var(--muted); border: 1px dashed var(--faint); border-radius: 5px; padding: 0 5px; margin-left: 6px;
  vertical-align: 1px; text-decoration: none;
}

/* Sidebar */
.side { display: grid; gap: 14px; }
@media (min-width: 960px) { .side { position: sticky; top: 80px; } }
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; }
.panel h3 { font-size: 15px; display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.panel h3 svg { color: var(--c); font-size: 17px; }
.panel ul { margin: 0; padding: 0; list-style: none; display: grid; gap: 6px; font-size: 14px; color: var(--muted); }
.panel li { padding-left: 14px; position: relative; }
.panel li::before { content: ""; position: absolute; left: 0; top: .7em; width: 5px; height: 5px; border-radius: 50%; background: var(--c); opacity: .7; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tag { font-size: 13px; background: var(--surface-2); border-radius: 7px; padding: 3px 9px; color: var(--text); }
.related { display: grid; gap: 8px; }
.related a {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 10px 12px; border-radius: 10px; background: var(--surface-2); font-size: 14px; font-weight: 500;
}
.related a:hover { outline: 1px solid var(--rc); }
.related a small { color: var(--rc); font-size: 12px; font-weight: 600; white-space: nowrap; }

/* ---------- Navigation ---------- */
.topnav { display: flex; gap: 4px; margin-left: auto; margin-right: 10px; }
.topnav a { padding: 7px 12px; border-radius: 9px; font-size: 14px; font-weight: 500; color: var(--muted); }
.topnav a:hover { color: var(--text); background: var(--surface-2); }
.topnav a.active { color: var(--text); background: var(--surface-2); }
.stat-link { color: var(--muted); }
.stat-link:hover { color: var(--text); }
.stat-link b { color: #10b981 !important; }

/* ---------- Ressources gratuites ---------- */
.kind {
  flex: none; display: inline-block; font-size: 11px; font-weight: 600; letter-spacing: .03em; text-transform: uppercase;
  border-radius: 5px; padding: 1px 6px; white-space: nowrap;
}
.kind-certif { color: #059669; background: color-mix(in srgb, #10b981 15%, transparent); }
.kind-cours  { color: #2563eb; background: color-mix(in srgb, #3b82f6 15%, transparent); }
.kind-labo   { color: #9333ea; background: color-mix(in srgb, #a855f7 15%, transparent); }
:root[data-theme="dark"] .kind-certif { color: #34d399; }
:root[data-theme="dark"] .kind-cours  { color: #60a5fa; }
:root[data-theme="dark"] .kind-labo   { color: #c084fc; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .kind-certif { color: #34d399; }
  :root:not([data-theme="light"]) .kind-cours  { color: #60a5fa; }
  :root:not([data-theme="light"]) .kind-labo   { color: #c084fc; }
}
.kind-icon-certif { --c: #10b981; }
.kind-icon-cours  { --c: #3b82f6; }
.kind-icon-labo   { --c: #a855f7; }

.free-list { gap: 12px !important; }
.free-list li { padding-left: 0 !important; }
.free-list li::before { display: none; }
.free-list p { margin: 3px 0 0; font-size: 13px; line-height: 1.5; }
.free-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.free-top a { font-weight: 600; color: var(--text); }
.free-top a:hover { color: var(--c); text-decoration: underline; }
.more { display: inline-block; margin-top: 12px; font-size: 13px; color: var(--c); font-weight: 500; }
.more:hover { text-decoration: underline; }

.hero-small { padding-bottom: 8px; }
.hero .note { font-size: 13px; color: var(--faint); margin: 12px 0 0; }
.free-card { --c: var(--border); }
.free-card::before { display: none; }
.free-card:hover { transform: none; }
.free-card h3 a:hover { text-decoration: underline; }
.free-card h3 svg { font-size: 14px; color: var(--faint); vertical-align: -1px; }
.free-card .by { font-size: 12px; color: var(--faint); text-align: right; }
.uses { display: flex; flex-wrap: wrap; gap: 5px; }
.uses .tag { font-size: 12px; padding: 2px 8px; border: 1px solid transparent; }
.uses .tag:hover { border-color: var(--rc); }
[hidden] { display: none !important; }

/* ---------- Compte ---------- */
.account {
  display: flex; align-items: center; gap: 8px; margin-right: 10px; font-size: 13px;
  border: 1px solid var(--border); background: var(--surface); border-radius: 10px; padding: 6px 10px;
  max-width: 260px; min-width: 0;
}
.account-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.account-logout { color: var(--faint); white-space: nowrap; }
.account-logout:hover { color: var(--text); text-decoration: underline; }
.sync-dot { flex: none; width: 8px; height: 8px; border-radius: 50%; background: var(--faint); }
.sync-saved { background: #10b981; }
.sync-saving { background: #f59e0b; }
.sync-error { background: #ef4444; }

a.account-name:hover { text-decoration: underline; }
button.account-logout { background: none; border: 0; padding: 0; font: inherit; cursor: pointer; }

/* ---------- Écrans de connexion ---------- */
body.gated .topnav, body.gated .account { display: none !important; }
.auth { min-height: calc(100vh - 200px); display: grid; place-items: center; padding: 40px 0; }
.auth-card {
  width: 100%; max-width: 380px; display: grid; gap: 14px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 18px;
  padding: 30px 26px; box-shadow: var(--shadow);
}
.auth-mark { width: 44px; height: 44px; border-radius: 12px; font-size: 24px; }
.auth-card h1 { font-size: 26px; }
.auth-sub { margin: -6px 0 4px; color: var(--muted); font-size: 14px; }
.auth-help { margin: 0; font-size: 13px; color: var(--faint); text-align: center; }
.auth-cancel { justify-self: center; }

.auth-card label, .profile-form label { display: grid; gap: 6px; font-size: 13px; font-weight: 600; color: var(--muted); }
.auth-card input, .profile-form input {
  font: 400 15px var(--font); color: var(--text); background: var(--bg);
  border: 1px solid var(--border); border-radius: 10px; padding: 11px 12px; width: 100%; min-width: 0;
}
.auth-card input:focus, .profile-form input:focus { outline: none; border-color: #3b82f6; box-shadow: 0 0 0 3px color-mix(in srgb, #3b82f6 25%, transparent); }
.code-input { font: 600 22px var(--display) !important; letter-spacing: .4em; text-align: center; }

.btn-primary, .btn-secondary {
  font: 600 14px var(--font); border-radius: 10px; padding: 11px 16px; cursor: pointer;
  border: 1px solid transparent; justify-self: start;
}
.auth-card .btn-primary { justify-self: stretch; }
.btn-primary { background: #3b82f6; color: #fff; }
.btn-primary:hover { background: #2563eb; }
.btn-secondary { background: var(--surface-2); color: var(--text); border-color: var(--border); }
.btn-secondary:hover { border-color: var(--faint); }
.btn-primary:disabled, .btn-secondary:disabled { opacity: .6; cursor: default; }
.form-error { margin: 0; color: #dc2626; font-size: 14px; }
.form-ok { margin: 0; color: #059669; font-size: 14px; }
:root[data-theme="dark"] .form-error { color: #f87171; }
:root[data-theme="dark"] .form-ok { color: #34d399; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .form-error { color: #f87171; }
  :root:not([data-theme="light"]) .form-ok { color: #34d399; }
}

/* ---------- Profil ---------- */
.profile-grid { display: grid; gap: 16px; margin-top: 24px; grid-template-columns: repeat(auto-fit, minmax(290px, 1fr)); align-items: start; }
.profile-form { display: grid; gap: 12px; }
.profile-form h2 { font-size: 18px; }
.profile-form .muted { margin: -4px 0 0; font-size: 14px; color: var(--muted); }
#mfa-body { display: grid; gap: 12px; }
.mfa-state { margin: 0; font-weight: 600; display: flex; align-items: center; gap: 6px; }
.mfa-on { color: #059669; }
.mfa-enroll { display: grid; gap: 12px; }
.mfa-steps { margin: 0; padding-left: 20px; font-size: 14px; color: var(--muted); }
.mfa-qr { justify-self: start; background: #fff; padding: 10px; border-radius: 12px; line-height: 0; }
.mfa-secret { margin: 0; font-size: 13px; color: var(--muted); word-break: break-all; }
.mfa-secret code { font-size: 12px; background: var(--surface-2); padding: 2px 6px; border-radius: 5px; color: var(--text); }
.mfa-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.who { display: grid; min-width: 0; }
.who strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.who-mail { font-size: 12px; color: var(--faint); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Équipe ---------- */
.team-toolbar { display: flex; align-items: center; gap: 10px; margin: 24px 0 18px; font-size: 14px; color: var(--muted); }
.team-toolbar select {
  font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; padding: 8px 12px; max-width: 100%; min-width: 0;
}
.team-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.member header { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; margin-bottom: 12px; }
.member header strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.member header small { color: var(--faint); white-space: nowrap; }
.member .muted { color: var(--faint); font-size: 14px; margin: 0; }
.member-jobs { gap: 10px !important; }
.member-jobs li {
  padding-left: 0 !important; display: grid; grid-template-columns: minmax(0, 1fr) 80px 40px;
  align-items: center; gap: 10px; color: var(--text);
}
.member-jobs li::before { display: none; }
.member-jobs a { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.member-jobs a:hover { text-decoration: underline; }
.pct { font-size: 13px; color: var(--muted); text-align: right; font-variant-numeric: tabular-nums; }
.team-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.team-table th { text-align: left; font-size: 12px; color: var(--faint); text-transform: uppercase; letter-spacing: .05em; padding: 0 10px 10px; }
.team-table td { padding: 10px; border-top: 1px solid var(--border); }
.team-table .progress-line { display: flex; align-items: center; gap: 10px; min-width: 140px; }
.team-table .bar { flex: 1; }
.panel:has(.team-table) { overflow-x: auto; }

.account-logout { display: inline-flex; align-items: center; gap: 5px; }
.account-logout svg { font-size: 15px; }

@media (max-width: 640px) {
  .account-name, .account-logout span { display: none; }
  .account { margin-right: 6px; }
}

@media (max-width: 420px) {
  .brand-text { display: none; }
}

@media (max-width: 480px) {
  .topnav a { padding: 7px 8px; }
  .brand { font-size: 17px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; scroll-behavior: auto !important; }
}
