/* Base du site Diamix Studio : DA neutre provisoire, clair / sombre.
   Toutes les couleurs passent par ces jetons : la future DA n'aura qu'à les
   redéfinir ici, sans toucher aux pages. */

:root {
  --bg: #fafafa;
  --surface: #ffffff;
  --surface-2: #f4f4f5;
  --text: #18181b;
  --muted: #71717a;
  --border: #e4e4e7;
  --accent: #18181b;
  --accent-text: #ffffff;
  --focus: #3b82f6;
  --danger: #dc2626;
  --danger-bg: #fef2f2;
  --ok: #15803d;
  --ok-bg: #f0fdf4;
  --viz-accent: #2a78d6;
  --viz-muted: #a1a1aa;
  --viz-grid: #e4e4e7;
  --viz-axis: #c3c2b7;
  --delta-up: #006300;
  --delta-down: #c93b3a;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(0, 0, 0, .04), 0 4px 16px rgba(0, 0, 0, .04);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #09090b;
    --surface: #131316;
    --surface-2: #1c1c20;
    --text: #fafafa;
    --muted: #a1a1aa;
    --border: #27272a;
    --accent: #fafafa;
    --accent-text: #09090b;
    --focus: #60a5fa;
    --danger: #f87171;
    --danger-bg: #2a1414;
    --ok: #4ade80;
    --ok-bg: #0f2417;
    --shadow: none;
    --viz-accent: #3987e5;
    --viz-muted: #52525b;
    --viz-grid: #2c2c2a;
    --viz-axis: #383835;
    --delta-up: #0ca30c;
    --delta-down: #e66767;
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #09090b;
  --surface: #131316;
  --surface-2: #1c1c20;
  --text: #fafafa;
  --muted: #a1a1aa;
  --border: #27272a;
  --accent: #fafafa;
  --accent-text: #09090b;
  --focus: #60a5fa;
  --danger: #f87171;
  --danger-bg: #2a1414;
  --ok: #4ade80;
  --ok-bg: #0f2417;
  --shadow: none;
  --viz-accent: #3987e5;
  --viz-muted: #52525b;
  --viz-grid: #2c2c2a;
  --viz-axis: #383835;
  --delta-up: #0ca30c;
  --delta-down: #e66767;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }

html, body { margin: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: "Geist", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-feature-settings: "ss01", "cv11";
  transition: background-color .3s ease, color .3s ease;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

[hidden] { display: none !important; }

a { color: inherit; }

/* ---------- En-tête ---------- */

/* Au-dessus du contenu : le menu du compte (js/account-menu.js) en déborde. */
.site-header {
  position: relative;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 960px;
  margin: 0 auto;
  padding: 16px;
}

.brand {
  font-weight: 700;
  letter-spacing: -.01em;
  text-decoration: none;
}

/* ---------- Mise en page ---------- */

.page {
  max-width: 560px;
  margin: 0 auto;
  padding: 8px 16px 64px;
}

.page h1 {
  font-size: 26px;
  letter-spacing: -.02em;
  margin: 16px 0 4px;
}

.lead { color: var(--muted); margin: 0 0 24px; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
  margin-bottom: 16px;
}

.card h2 {
  font-size: 16px;
  margin: 0 0 16px;
}

.card-note { color: var(--muted); font-size: 14px; margin: 0; }

/* ---------- Formulaires ---------- */

.field { display: block; margin-bottom: 16px; }

.field > span {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 6px;
}

.field small { display: block; color: var(--muted); font-size: 12px; margin-top: 6px; }

.input {
  width: 100%;
  font: inherit;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
}

.input:focus { outline: 2px solid var(--focus); outline-offset: -1px; border-color: transparent; }

.input[readonly] { color: var(--muted); background: var(--surface-2); }

.input-prefix { display: flex; align-items: stretch; }

.input-prefix > span {
  display: flex;
  align-items: center;
  padding: 0 10px;
  color: var(--muted);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-right: 0;
  border-radius: var(--radius-sm) 0 0 var(--radius-sm);
}

.input-prefix .input { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }

.check {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  font-size: 14px;
  margin-bottom: 16px;
}

.check input { margin-top: 3px; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font: inherit;
  font-weight: 600;
  border-radius: var(--radius-sm);
  padding: 10px 16px;
  cursor: pointer;
  border: 1px solid transparent;
  text-decoration: none;
}

.btn:disabled { opacity: .5; cursor: default; }

.btn-primary { background: var(--accent); color: var(--accent-text); }

.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border); }

.btn-ghost { background: transparent; color: var(--muted); padding-left: 0; padding-right: 0; }

.btn-block { width: 100%; }

.link-btn {
  border: 0;
  background: none;
  padding: 0;
  font: inherit;
  font-size: 14px;
  color: var(--muted);
  text-decoration: underline;
  cursor: pointer;
}

.divider {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--muted);
  font-size: 13px;
  margin: 16px 0;
}

.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--border); }

.msg {
  font-size: 14px;
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  margin-bottom: 16px;
}

.msg-error { color: var(--danger); background: var(--danger-bg); }

.msg-ok { color: var(--ok); background: var(--ok-bg); }

/* ---------- Onglets ---------- */

.tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 4px;
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  margin-bottom: 20px;
}

.tabs button {
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-weight: 600;
  padding: 8px;
  border-radius: 6px;
  cursor: pointer;
}

.tabs button[aria-selected="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }

/* ---------- Compte ---------- */

.identity { display: flex; align-items: center; gap: 16px; margin-bottom: 24px; }

.avatar {
  position: relative;
  flex: none;
  width: 72px;
  height: 72px;
  border-radius: 50%;
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--surface-2);
  padding: 0;
  cursor: pointer;
  font: inherit;
  color: var(--muted);
  font-size: 26px;
  font-weight: 700;
}

.avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }

.avatar-edit {
  position: absolute;
  inset: auto 0 0 0;
  font-size: 11px;
  font-weight: 600;
  background: rgba(0, 0, 0, .55);
  color: #fff;
  padding: 3px 0;
  opacity: 0;
  transition: opacity .15s;
}

.avatar:hover .avatar-edit, .avatar:focus-visible .avatar-edit { opacity: 1; }

.identity-text { min-width: 0; }

.identity-name { font-weight: 700; font-size: 18px; overflow-wrap: anywhere; }

.identity-handle { color: var(--muted); font-size: 14px; overflow-wrap: anywhere; }

.row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 0;
  border-top: 1px solid var(--border);
  font-size: 14px;
}

.row:first-of-type { border-top: 0; }

.row-label { color: var(--muted); }

.badge {
  display: inline-block;
  font-size: 12px;
  font-weight: 600;
  padding: 2px 10px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
}

.actions { display: flex; gap: 8px; flex-wrap: wrap; }

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

.scope-list { margin: 0 0 16px; padding-left: 20px; font-size: 14px; }

.scope-list li { margin-bottom: 4px; }

.code-input { font-family: "Geist Mono", ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 12px; }

.notice {
  font-size: 14px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  margin-bottom: 16px;
}

.env-tag {
  position: fixed;
  bottom: 12px;
  right: 12px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--muted);
  border: 1px dashed var(--border);
  border-radius: 6px;
  padding: 2px 8px;
  background: var(--surface);
}

@media (max-width: 480px) {
  .card { padding: 18px; }
  .row { flex-wrap: wrap; }
}

/* ---------- Marque ---------- */

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.brand-logo {
  width: 32px;
  height: 32px;
  border-radius: 9px;
  display: block;
  transition: transform .4s cubic-bezier(.2, .8, .2, 1);
}

.brand:hover .brand-logo { transform: rotate(-8deg) scale(1.06); }

/* Le logo (img/brand/diamix-logo.webp) est blanc sur fond transparent : en
   thème clair il serait invisible, on l'inverse en noir. Les trois cas suivent
   les mêmes règles que les variables de thème plus haut (système, forcé clair,
   forcé sombre). Les onglets du navigateur, eux, ont leurs deux fichiers
   (favicon-noir / favicon-blanc). */
.brand-logo, .logo-ds { filter: invert(1); }

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .brand-logo,
  :root:not([data-theme="light"]) .logo-ds { filter: none; }
}

:root[data-theme="dark"] .brand-logo,
:root[data-theme="dark"] .logo-ds { filter: none; }

/* ---------- Apps ---------- */

.app-row { padding: 14px 0; }

.app-id { display: inline-flex; align-items: center; gap: 14px; }

.app-icon {
  width: 44px;
  height: 44px;
  border-radius: 11px;
  display: block;
  box-shadow: 0 0 0 1px var(--border);
  transition: transform .3s cubic-bezier(.2, .8, .2, 1);
}

.app-row:hover .app-icon { transform: scale(1.06); }

.app-name { font-weight: 600; font-size: 15px; }

/* ---------- Cartes ---------- */

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.card-head h2 { margin: 0; }

.card { transition: border-color .25s ease; }

.card:hover { border-color: color-mix(in srgb, var(--text) 16%, transparent); }

.card-disabled { opacity: .55; }

.card-disabled:hover { border-color: var(--border); }

/* ---------- Navigation (js/layout.js) ---------- */

.site-header { gap: 16px; }

.site-nav { display: flex; gap: 4px; margin-left: auto; margin-right: 8px; }

.site-nav a {
  color: var(--muted);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  padding: 6px 10px;
  border-radius: 8px;
  transition: color .2s ease, background-color .2s ease;
}

.site-nav a:hover { color: var(--text); }

.site-nav a[aria-current="page"] { color: var(--text); background: var(--surface-2); }

@media (max-width: 720px) {
  .site-header { flex-wrap: wrap; }
  .site-nav { order: 3; width: 100%; margin: 0; overflow-x: auto; }
  .brand span { display: none; }
}

.page-wide { max-width: 880px; }

.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; }

/* ---------- Accueil ---------- */

.hero { padding: 48px 0 32px; }

.hero h1 { font-size: clamp(34px, 6vw, 56px); line-height: 1.05; letter-spacing: -.035em; margin: 8px 0 16px; }

.hero .lead { font-size: 17px; max-width: 560px; }

.eyebrow {
  margin: 0;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--muted);
}

.home-section { margin-top: 40px; }

.section-title { font-size: 18px; margin: 0 0 16px; letter-spacing: -.01em; }

.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }

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

.app-card { margin: 0; display: flex; flex-direction: column; gap: 4px; transition: border-color .25s ease, transform .25s cubic-bezier(.2, .8, .2, 1); }

.app-card:hover { transform: translateY(-2px); }

.app-card h3 { margin: 12px 0 0; font-size: 17px; }

.app-card-head { display: flex; align-items: flex-start; justify-content: space-between; }

.app-icon-lg { width: 64px; height: 64px; border-radius: 16px; }

.app-card-next { border-style: dashed; background: transparent; box-shadow: none; }

.app-next-mark {
  width: 64px;
  height: 64px;
  border-radius: 16px;
  border: 1px dashed var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  color: var(--muted);
}

.site-footer {
  max-width: 880px;
  margin: 24px auto 0;
  padding: 24px 16px 40px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 13px;
}

.site-footer a { color: var(--muted); text-decoration: none; }

.site-footer a:hover { color: var(--text); }

/* ---------- News ---------- */

.news-list { display: grid; gap: 12px; }

.news-card { display: block; margin: 0; color: inherit; text-decoration: none; transition: border-color .25s ease, transform .25s cubic-bezier(.2, .8, .2, 1); }

.news-card:hover { transform: translateY(-2px); }

.news-card h2, .news-card h3 { margin: 4px 0 6px; font-size: 18px; }

.news-draft { border-style: dashed; }

.news-meta { margin: 0; color: var(--muted); font-size: 13px; }

.news-title { font-size: clamp(28px, 5vw, 40px); line-height: 1.1; letter-spacing: -.025em; margin: 6px 0 16px; overflow-wrap: anywhere; }

.news-admin { display: flex; align-items: center; gap: 8px; margin-bottom: 24px; }

.prose { font-size: 16px; line-height: 1.7; overflow-wrap: anywhere; }

.prose h2 { font-size: 24px; margin: 32px 0 8px; letter-spacing: -.02em; }

.prose h3 { font-size: 19px; margin: 24px 0 8px; }

.prose h4 { font-size: 16px; margin: 20px 0 6px; }

.prose p, .prose ul, .prose blockquote { margin: 0 0 16px; }

.prose ul { padding-left: 22px; }

.prose li { margin-bottom: 4px; }

.prose blockquote { border-left: 3px solid var(--border); padding-left: 14px; color: var(--muted); }

.prose code { font-family: "Geist Mono", ui-monospace, monospace; font-size: .9em; background: var(--surface-2); border-radius: 5px; padding: 1px 5px; }

.prose img { max-width: 100%; border-radius: var(--radius); display: block; margin: 8px 0; }

.prose a { text-underline-offset: 3px; }

.editor-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }

@media (max-width: 760px) { .editor-grid { grid-template-columns: 1fr; } }

textarea.input { resize: vertical; line-height: 1.5; }

.editor-body { font-family: "Geist Mono", ui-monospace, monospace; font-size: 13px; }

.preview-label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; }

.preview { max-height: 640px; overflow: auto; margin: 0; }

.preview .news-title { font-size: 26px; }

/* ---------- Stats (méthode dataviz : une couleur par graphique, repères
   discrets, texte en encre, jamais dans la couleur de la courbe) ---------- */

.segmented {
  display: inline-flex;
  padding: 3px;
  gap: 2px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  align-self: center;
}

.segmented button {
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: 7px;
  cursor: pointer;
  transition: background-color .2s ease, color .2s ease;
}

.segmented button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }

.stats-apps { display: grid; gap: 28px; margin-top: 8px; }

.stats-app { display: grid; gap: 14px; }

.stats-card { margin: 0; }

.stats-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }

.stats-updated { color: var(--muted); font-size: 12px; }

.stat-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; }

.stat-tile {
  display: grid;
  gap: 4px;
  text-align: left;
  font: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: border-color .25s ease, transform .25s cubic-bezier(.2, .8, .2, 1);
  animation: rise .45s cubic-bezier(.2, .8, .2, 1) both;
}

.stat-tile:nth-child(2) { animation-delay: .04s; }
.stat-tile:nth-child(3) { animation-delay: .08s; }
.stat-tile:nth-child(4) { animation-delay: .12s; }
.stat-tile:nth-child(5) { animation-delay: .16s; }
.stat-tile:nth-child(n+6) { animation-delay: .2s; }

.stat-tile:hover { transform: translateY(-2px); border-color: color-mix(in srgb, var(--text) 18%, transparent); }

.stat-tile.is-selected { border-color: var(--viz-accent); box-shadow: 0 0 0 1px var(--viz-accent) inset; }

.stat-tile:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

.stat-label { color: var(--muted); font-size: 13px; }

.stat-value { font-size: 30px; font-weight: 700; letter-spacing: -.025em; line-height: 1.15; }

.stat-delta { font-size: 12px; font-weight: 600; color: var(--muted); }

.stat-delta.is-up { color: var(--delta-up); }

.stat-delta.is-down { color: var(--delta-down); }

.spark { margin-top: 6px; overflow: visible; }

/* Élan du profil : total à vie, puis la part de chaque app (/stats, /u/…) */
.elan-card { display: grid; gap: 4px; }

.elan-card p { margin: 0; }

.elan-total { font-size: 40px; font-weight: 700; letter-spacing: -.03em; line-height: 1.1; font-variant-numeric: tabular-nums; }

.elan-split { list-style: none; margin: 14px 0 0; padding: 0; display: grid; gap: 12px; }

.elan-row { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 6px 12px; }

.elan-name { display: flex; align-items: center; gap: 8px; min-width: 0; }

.elan-icon { border-radius: 6px; }

.elan-value { font-weight: 600; font-variant-numeric: tabular-nums; }

.elan-bar { grid-column: 1 / -1; height: 6px; border-radius: 3px; background: var(--viz-grid); overflow: hidden; }

.elan-fill { display: block; height: 100%; border-radius: inherit; background: var(--viz-accent); }

.spark-line { fill: none; stroke: var(--viz-muted); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.stat-tile.is-selected .spark-line { stroke: var(--viz-accent); }

.spark-dot { fill: var(--viz-accent); stroke: var(--surface); stroke-width: 2; }

.chart-card { margin: 0; animation: rise .5s cubic-bezier(.2, .8, .2, 1) .1s both; }

.chart-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 8px; }

.chart-title { margin: 0; font-size: 16px; }

.chart-head .card-note { font-size: 13px; }

.chart-box { position: relative; outline: none; border-radius: var(--radius-sm); }

.chart-box:focus-visible { box-shadow: 0 0 0 2px var(--focus); }

.chart { display: block; overflow: visible; }

.chart .grid { stroke: var(--viz-grid); stroke-width: 1; }

.chart .axis { stroke: var(--viz-axis); stroke-width: 1; }

.chart .tick { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }

.chart .line { fill: none; stroke: var(--viz-accent); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.chart .area { animation: fade-in .9s ease .3s both; }

.chart .area-stop-top { stop-color: var(--viz-accent); stop-opacity: .22; }

.chart .area-stop-bottom { stop-color: var(--viz-accent); stop-opacity: 0; }

.chart .end-dot { fill: var(--viz-accent); stroke: var(--surface); stroke-width: 2; }

.chart .crosshair { stroke: var(--viz-axis); stroke-width: 1; }

.chart .hit { fill: transparent; cursor: crosshair; }

.chart-tip {
  position: absolute;
  transform: translate(-50%, -100%);
  pointer-events: none;
  display: grid;
  gap: 2px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: 0 8px 24px rgba(0, 0, 0, .25);
  white-space: nowrap;
  font-size: 12px;
}

.chart-tip strong { font-size: 15px; }

.chart-tip span { color: var(--muted); }

.chart-hint { margin-top: 8px; }

.data-table { width: 100%; border-collapse: collapse; margin-top: 12px; font-size: 13px; }

.data-table th, .data-table td { text-align: left; padding: 8px 4px; border-top: 1px solid var(--border); }

.data-table th { color: var(--muted); font-weight: 600; }

.data-table .num { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- Profil public (/u/pseudo) ---------- */

.back-link {
  display: inline-block;
  color: var(--muted);
  text-decoration: none;
  font-size: 14px;
  margin: 8px 0 16px;
  transition: color .2s ease, transform .2s ease;
}

.back-link:hover { color: var(--text); transform: translateX(-2px); }

.profile-hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 36px 24px 28px;
}

.profile-hero h1 { margin: 16px 0 2px; font-size: 24px; overflow-wrap: anywhere; }

.profile-handle { color: var(--muted); margin: 0; overflow-wrap: anywhere; }

.profile-since { color: var(--muted); font-size: 13px; margin: 6px 0 20px; }

.profile-hero .msg { width: 100%; }

.profile-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px;
  min-height: 42px;
}

.avatar-lg {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  overflow: hidden;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--muted);
  font-weight: 700;
  font-size: 36px;
  animation: pop .5s cubic-bezier(.2, .8, .2, 1) both;
}

.avatar-lg img { width: 100%; height: 100%; object-fit: cover; display: block; }

@keyframes pop {
  from { opacity: 0; transform: scale(.9); }
  to { opacity: 1; transform: none; }
}

.profile-link {
  display: inline-block;
  margin-top: 4px;
  font-size: 13px;
  color: var(--muted);
  transition: color .2s ease;
}

.profile-link:hover { color: var(--text); }

a.friend-who { color: inherit; text-decoration: none; border-radius: var(--radius-sm); }

a.friend-who:hover .friend-name { text-decoration: underline; text-underline-offset: 3px; }

/* ---------- Zone sensible ---------- */

.card-danger { border-color: color-mix(in srgb, var(--danger) 35%, var(--border)); }

.card-danger:hover { border-color: color-mix(in srgb, var(--danger) 55%, var(--border)); }

.btn-danger { background: var(--danger); color: #fff; }

.btn-danger-outline { background: transparent; color: var(--danger); border-color: color-mix(in srgb, var(--danger) 45%, transparent); }

.btn-danger-outline:hover:not(:disabled) { background: var(--danger-bg); }

/* ---------- Bannière du profil (/compte, /u/…) ---------- */

.btn-sm { padding: 7px 12px; font-size: 14px; }

.banner {
  position: relative;
  aspect-ratio: 3 / 1;
  overflow: hidden;
  border-radius: var(--radius-sm);
  background:
    radial-gradient(120% 140% at 0% 0%, color-mix(in srgb, var(--viz-accent) 22%, transparent), transparent 60%),
    radial-gradient(120% 140% at 100% 100%, color-mix(in srgb, #b9aeea 26%, transparent), transparent 60%),
    var(--surface-2);
}

.banner img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  user-select: none;
  -webkit-user-drag: none;
}

.banner-edit { margin-bottom: 20px; }

.banner-edit .banner[data-empty="false"] { cursor: grab; touch-action: none; }

.banner-edit .banner.is-dragging { cursor: grabbing; }

.banner-hint {
  position: absolute;
  right: 10px;
  bottom: 10px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  color: #fff;
  background: rgba(0, 0, 0, .55);
  opacity: 0;
  transition: opacity .2s ease;
  pointer-events: none;
}

.banner:hover .banner-hint, .banner.is-dragging .banner-hint { opacity: 1; }

@media (hover: none) {
  .banner-hint { opacity: 1; }
}

.banner-actions { display: flex; gap: 12px; align-items: center; margin-top: 10px; }

/* Sur le profil, la bannière occupe le haut de la carte, et la photo la chevauche. */
.profile-hero { overflow: hidden; }

.profile-banner {
  align-self: stretch;
  margin: -36px -24px 0;
  border-radius: 0;
}

.profile-banner + #pv-avatar { margin-top: -48px; position: relative; }

.profile-banner + #pv-avatar .avatar-lg { box-shadow: 0 0 0 4px var(--surface); }

/* ---------- Succès des apps (/compte, /u/…) ---------- */

.ach-group + .ach-group { margin-top: 20px; }

.ach-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }

.ach-head h3 {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0;
}

.ach-count { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }

.ach-bar {
  height: 4px;
  margin: 8px 0 4px;
  border-radius: 999px;
  background: var(--surface-2);
  overflow: hidden;
}

.ach-bar::after {
  content: "";
  display: block;
  height: 100%;
  width: calc(var(--ach-p, 0) * 100%);
  border-radius: inherit;
  background: var(--text);
  transition: width .6s cubic-bezier(.2, .8, .2, 1);
}

/* Une grille de badges seuls : le détail s'ouvre au clic (badge-viewer.js). */
.ach-list {
  list-style: none;
  margin: 10px 0 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(88px, 1fr));
  gap: 8px;
}

.ach-item {
  display: flex;
  align-items: center;
  justify-content: center;
  aspect-ratio: 1;
  border-radius: var(--radius-sm);
}

.ach-item .ach-medal-3d { --medal: 76px; }

/* La médaille dessinée (Mavelo, Lirevo, badge Halo sans bande cuite). */
.ach-medal.ach-medal-flat {
  --size: 64px;
  width: var(--size);
  height: var(--size);
  border-radius: 50%;
  color: #1a1a1a;
  font-weight: 700;
  font-size: calc(var(--size) * .4);
  background:
    radial-gradient(circle at 32% 28%, rgba(255, 255, 255, .75), transparent 42%),
    radial-gradient(circle at 50% 50%, var(--ach-tint) 0 58%, color-mix(in srgb, var(--ach-tint) 55%, #000) 59% 63%, color-mix(in srgb, var(--ach-tint) 80%, #fff) 64% 100%);
  box-shadow:
    inset 0 -3px 6px rgba(0, 0, 0, .25),
    inset 0 2px 3px rgba(255, 255, 255, .5),
    0 4px 10px rgba(0, 0, 0, .28);
}

.ach-medal-flat svg {
  width: 46%;
  height: 46%;
  fill: none;
  stroke: rgba(20, 20, 20, .82);
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.badge-viewer-art { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; }

.badge-viewer-art[hidden] { display: none; }

.badge-viewer-art .ach-medal-flat { --size: min(200px, 60%); animation: ach-flat-in .5s cubic-bezier(.2, .8, .2, 1); }

@keyframes ach-flat-in { from { transform: scale(.7) rotate(-12deg); opacity: 0; } }

@media (prefers-reduced-motion: reduce) {
  .badge-viewer-art .ach-medal-flat { animation: none; }
}

.ach-medal {
  flex: none;
  width: 56px;
  height: 59px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.ach-medal img { width: 100%; height: 100%; object-fit: contain; display: block; }

.ach-medal-blank {
  width: 48px;
  height: 48px;
  margin: 0 4px;
  border-radius: 50%;
  background: color-mix(in srgb, var(--ach-tint) 35%, var(--surface-2));
  font-weight: 700;
  color: var(--text);
}

.ach-locked .ach-medal { filter: grayscale(1); opacity: .35; }

.ach-text { min-width: 0; }

.ach-text p { margin: 0; }

.ach-name { font-weight: 600; font-size: 15px; }

.ach-locked .ach-name { color: var(--muted); }

.ach-desc { color: var(--muted); font-size: 14px; }

.ach-meta { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin-top: 4px !important; font-size: 12px; color: var(--muted); }

.ach-chip {
  padding: 1px 8px;
  border-radius: 999px;
  font-weight: 600;
  color: var(--text);
  background: color-mix(in srgb, var(--ach-tint) 30%, transparent);
  border: 1px solid color-mix(in srgb, var(--ach-tint) 60%, transparent);
}

/* ---------- Amis ---------- */

.inline-form { display: flex; gap: 8px; margin-bottom: 8px; }

.inline-form .input-prefix { flex: 1; min-width: 0; }

.friend-group { margin-top: 20px; }

.friend-group h3 {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 4px;
}

.friend-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-top: 1px solid var(--border);
  animation: rise .35s cubic-bezier(.2, .8, .2, 1) both;
}

.friend-list .friend-row:first-child { border-top: 0; }

.friend-who { display: flex; align-items: center; gap: 12px; min-width: 0; }

.friend-text { display: flex; flex-direction: column; min-width: 0; }

.friend-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.friend-handle { color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.friend-actions { display: flex; gap: 6px; flex: none; }

.friend-actions .btn { padding: 6px 12px; font-size: 13px; }

.friend-actions .btn-ghost { padding-left: 8px; padding-right: 8px; }

.friend-empty { margin-top: 8px; }

.avatar-sm {
  flex: none;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  overflow: hidden;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--muted);
  font-weight: 700;
  font-size: 14px;
}

.avatar-sm img { width: 100%; height: 100%; object-fit: cover; display: block; }

/* ---------- Animations ---------- */

@keyframes rise {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}

@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* Entrée d'un écran : ses blocs arrivent l'un après l'autre. */
.view-enter > * { animation: rise .5s cubic-bezier(.2, .8, .2, 1) both; }
.view-enter > *:nth-child(2) { animation-delay: .05s; }
.view-enter > *:nth-child(3) { animation-delay: .1s; }
.view-enter > *:nth-child(4) { animation-delay: .15s; }
.view-enter > *:nth-child(5) { animation-delay: .2s; }
.view-enter > *:nth-child(6) { animation-delay: .25s; }
.view-enter > *:nth-child(7) { animation-delay: .3s; }
.view-enter > *:nth-child(8) { animation-delay: .35s; }
.view-enter > *:nth-child(n+9) { animation-delay: .4s; }

.site-header { animation: fade-in .6s ease both; }

.msg:not([hidden]) { animation: rise .25s ease both; }

.btn {
  transition: transform .12s ease, background-color .2s ease, border-color .2s ease, opacity .2s ease, filter .2s ease;
}

.btn:active:not(:disabled) { transform: scale(.97); }

.btn-primary:hover:not(:disabled) { filter: brightness(.88); }

.btn-secondary:hover:not(:disabled) { border-color: color-mix(in srgb, var(--text) 30%, transparent); }

.btn-ghost:hover:not(:disabled) { color: var(--text); }

.input { transition: border-color .2s ease, background-color .2s ease; }

.tabs button { transition: background-color .25s ease, color .25s ease, box-shadow .25s ease; }


.avatar img { transition: transform .4s cubic-bezier(.2, .8, .2, 1); }

.avatar:hover img { transform: scale(1.06); }

.badge { transition: background-color .2s ease; }

/* Respect du réglage « réduire les animations » du système. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-delay: 0s !important;
    transition-duration: .01ms !important;
  }
}

/* ---------- Communauté (/communaute, et menus de modération du profil) ---------- */

.cm-head { align-items: flex-end; }

.cm-head .lead { margin-bottom: 20px; }

.cm-tabs { margin-bottom: 20px; }

.cm-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  margin-left: 4px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-text);
  font-size: 11px;
  font-weight: 700;
}

.cm-toolbar { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }

.cm-toolbar .input { flex: 1 1 220px; min-width: 0; }

.cm-list { display: grid; gap: 10px; }

.cm-forum {
  display: flex;
  align-items: center;
  gap: 16px;
  margin: 0;
  padding: 18px 20px;
  color: inherit;
  text-decoration: none;
  animation: rise .4s cubic-bezier(.2, .8, .2, 1) both;
  transition: border-color .25s ease, transform .25s cubic-bezier(.2, .8, .2, 1);
}

.cm-forum:hover { transform: translateY(-2px); }

.cm-forum-main { flex: 1; min-width: 0; }

.cm-forum-title { margin: 0 0 4px; font-size: 16px; letter-spacing: -.01em; overflow-wrap: anywhere; }

.cm-forum-excerpt {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow-wrap: anywhere;
}

.cm-meta { display: flex; align-items: center; gap: 8px; margin-top: 10px; color: var(--muted); font-size: 13px; min-width: 0; }

.cm-meta-name { color: var(--text); font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.cm-dot { opacity: .6; }

.cm-replies-count {
  flex: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 64px;
  padding: 8px 6px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--muted);
  font-size: 12px;
}

.cm-replies-count strong { color: var(--text); font-size: 18px; line-height: 1.2; font-variant-numeric: tabular-nums; }

.cm-empty { text-align: center; padding: 40px 24px; }

.cm-empty h2 { margin-bottom: 6px; }

.cm-members { padding-top: 8px; padding-bottom: 8px; }

.cm-members .card-note { padding: 16px 0; }

.avatar-xs {
  flex: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  overflow: hidden;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--muted);
  font-weight: 700;
  font-size: 10px;
}

.avatar-xs img { width: 100%; height: 100%; object-fit: cover; display: block; }

/* Un message (premier message d'un forum, ou réponse). */
.cm-post { padding: 20px; margin-bottom: 12px; animation: rise .4s cubic-bezier(.2, .8, .2, 1) both; }

.cm-post-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }

.cm-who { display: flex; align-items: center; gap: 12px; min-width: 0; color: inherit; text-decoration: none; }

a.cm-who:hover .friend-name { text-decoration: underline; text-underline-offset: 3px; }

.cm-you {
  margin-left: 6px;
  padding: 0 6px;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
}

.cm-thread-title { font-size: clamp(22px, 4vw, 30px); line-height: 1.15; letter-spacing: -.02em; margin: 18px 0 0; overflow-wrap: anywhere; }

.cm-body p { margin: 12px 0 0; white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.65; }

.cm-op .cm-body p { font-size: 16px; }

.cm-body a { text-underline-offset: 3px; }

.cm-masked { color: var(--muted); font-style: italic; }

.cm-masked .link-btn { font-style: normal; }

.cm-replies-title { margin: 28px 0 12px; font-size: 15px; color: var(--muted); font-weight: 600; }

.cm-composer { margin-top: 20px; }

.cm-composer .field { margin-bottom: 12px; }

.cm-composer-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; }

.cm-hint { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }

.cm-new { animation: cm-flash 1.6s ease both; }

@keyframes cm-flash {
  from { border-color: var(--focus); box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 25%, transparent); }
  to { border-color: var(--border); box-shadow: var(--shadow); }
}

/* Menu « ⋯ » (details/summary). */
.cm-menu { position: relative; flex: none; }

.cm-menu summary {
  list-style: none;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  color: var(--muted);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  user-select: none;
  transition: background-color .2s ease, color .2s ease;
}

.cm-menu summary::-webkit-details-marker { display: none; }

.cm-menu summary:hover, .cm-menu[open] summary { background: var(--surface-2); color: var(--text); }

.cm-menu summary:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; }

.cm-menu-list {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  z-index: 20;
  min-width: 200px;
  display: grid;
  padding: 4px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: 0 12px 32px -12px rgba(0, 0, 0, .35);
  animation: rise .18s ease both;
}

.cm-menu-list button {
  border: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 14px;
  text-align: left;
  padding: 8px 10px;
  border-radius: 6px;
  cursor: pointer;
  white-space: nowrap;
}

.cm-menu-list button:hover, .cm-menu-list button:focus-visible { background: var(--surface-2); outline: none; }

.cm-menu-list .cm-menu-danger { color: var(--danger); }

.friend-actions { align-items: center; }

.btn-danger { background: var(--danger); color: #fff; }

.btn-danger:hover:not(:disabled) { filter: brightness(.92); }

/* Fenêtres (créer un forum, signaler). */
.cm-dialog {
  width: min(520px, calc(100% - 32px));
  max-height: calc(100% - 32px);
  padding: 24px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 24px 64px -24px rgba(0, 0, 0, .5);
}

.cm-dialog[open] { animation: pop .25s cubic-bezier(.2, .8, .2, 1) both; }

.cm-dialog::backdrop { background: rgba(0, 0, 0, .45); backdrop-filter: blur(3px); }

.cm-dialog h2 { font-size: 18px; margin: 0 0 4px; }

.cm-dialog > form > .card-note { margin-bottom: 18px; }

.cm-reasons { border: 0; padding: 0; margin: 0 0 8px; }

.cm-reasons legend { font-size: 13px; font-weight: 600; margin-bottom: 8px; padding: 0; }

.cm-reasons .check { margin-bottom: 8px; cursor: pointer; }

.cm-dialog-actions { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 8px; margin-top: 4px; }

@media (max-width: 480px) {
  .cm-forum { padding: 16px; gap: 12px; }
  .cm-replies-count { min-width: 52px; }
  .cm-post { padding: 16px; }
  .cm-members { padding-left: 16px; padding-right: 16px; }
  .cm-members .friend-row { flex-wrap: wrap; }
  .cm-members .friend-actions { margin-left: 48px; }
}

/* ---------- Compte : pleine largeur sur PC (compte.js, show) ---------- */

.is-wide .site-header { max-width: 1440px; padding-left: 32px; padding-right: 32px; }

.page.page-account { max-width: 1440px; padding-left: 32px; padding-right: 32px; }

@media (max-width: 720px) {
  .is-wide .site-header { padding-left: 16px; padding-right: 16px; }
  .page.page-account { padding-left: 16px; padding-right: 16px; }
}

.account-cols { display: grid; grid-template-columns: minmax(0, 1fr); column-gap: 16px; align-items: start; }

.account-col { min-width: 0; }

.account-col > .actions { margin-bottom: 16px; }

@media (min-width: 760px) {
  .account-cols { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .account-col:nth-child(3) { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 16px; align-items: start; }
  .account-col:nth-child(3) > .actions { grid-column: 1 / -1; }
}

@media (min-width: 1100px) {
  .account-cols { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .account-col:nth-child(3) { grid-column: auto; display: block; }

  /* Bannière plus allongée sur grand écran : elle reste un bandeau. */
  .account-profile .banner { aspect-ratio: 4 / 1; }

  .profile-form { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto; column-gap: 16px; align-items: start; }

  .profile-form-save { padding-top: 25px; }
}

/* Amis : un onglet à la fois, liste courte (compte.js, renderFriendList) */

.friend-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  padding: 4px;
  margin: 16px 0 8px;
  background: var(--surface-2);
  border-radius: var(--radius-sm);
}

.friend-tabs button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  padding: 7px 6px;
  border-radius: 6px;
  cursor: pointer;
  white-space: nowrap;
}

.friend-tabs button[aria-selected="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }

.friend-tab-n {
  min-width: 18px;
  padding: 0 5px;
  border-radius: 999px;
  font-size: 11px;
  line-height: 18px;
  background: var(--border);
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.friend-tab-n:empty { display: none; }

.friend-filter { margin: 4px 0 6px; padding: 8px 12px; font-size: 14px; }

/* Liste dépliée : elle défile dans la carte au lieu de l'allonger. */
.friend-list.is-expanded { max-height: 420px; overflow-y: auto; overscroll-behavior: contain; padding-right: 4px; }

.friend-list .friend-row:first-child { border-top: 0; }

.friend-more { display: block; margin: 8px auto 0; font-weight: 600; }

/* Tes apps : relié / actif (compte.js, renderApps) */

.app-text { display: flex; flex-direction: column; min-width: 0; }

.app-detail { color: var(--muted); font-size: 13px; }

.app-side { display: inline-flex; align-items: center; gap: 10px; flex: none; }

.app-get { font-size: 13px; font-weight: 600; color: var(--muted); }

.app-get:hover { color: var(--text); }

/* Mavelo web : l'app ouverte dans le navigateur, mise en avant. */
.app-web { padding: 5px 12px; border-radius: 999px; color: var(--accent-text); background: var(--accent); text-decoration: none; }

.app-web:hover { color: var(--accent-text); opacity: .88; }

.app-state-active {
  color: var(--text);
  background: color-mix(in srgb, var(--tint) 22%, transparent);
  border-color: color-mix(in srgb, var(--tint) 65%, transparent);
}

.app-state-idle { color: var(--text); }

.app-state-none { color: var(--muted); background: transparent; }

/* Lueur d'édition du profil (compte.js, wrapGlow) : le contour de l'accueil,
   sans la carte autour (pas de fond, de bord ni d'ombre en plus). */
.glow-field.border-glow-card {
  border: 0;
  box-shadow: none;
  background: transparent;
}

.glow-field > .border-glow-inner { overflow: visible; }

.glow-field-round { display: inline-grid; flex: none; }

.glow-field .banner { width: 100%; }

/* Badges 3D (achievements.js) : une bande de 17 vues, on montre la --f-ième */

.ach-medal-3d {
  --medal: 64px;
  width: var(--medal);
  height: var(--medal);
  overflow: hidden;
  display: block;
}

.ach-medal.ach-medal-3d img {
  width: calc(var(--medal) * 17);
  height: var(--medal);
  max-width: none;
  object-fit: fill;
  transform: translateX(calc(var(--f, 5) * var(--medal) * -1));
  user-select: none;
  -webkit-user-drag: none;
}

.ach-item:not(.ach-locked) .ach-medal-3d { filter: drop-shadow(0 4px 10px rgba(0, 0, 0, .28)); }

/* Le contour lumineux tient lieu d'anneau de focus (il n'est posé que sans
   prefers-reduced-motion : sinon l'anneau bleu reste). */
.glow-field .input:focus { outline: 0; border-color: color-mix(in srgb, var(--text) 30%, transparent); }


/* Carte Profil : bannière en haut, photo en haut à gauche à cheval sur son
   bord bas (compte.html, .profile-head). */
.account-profile .banner-edit { margin: -8px -8px 0; }

.profile-head {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  flex-wrap: wrap;
  padding: 0 8px;
  margin-bottom: 20px;
}

/* La photo (ou son enveloppe lumineuse) remonte sur la bannière. */
.profile-head > :first-child { margin-top: -48px; position: relative; z-index: 2; }

.profile-head .avatar {
  width: 104px;
  height: 104px;
  font-size: 36px;
  box-shadow: 0 0 0 5px var(--surface);
}

.profile-head .identity-text { flex: 1; min-width: 160px; padding-top: 10px; }

.profile-head .banner-actions { margin: 14px 0 0; }

.profile-form-save { margin-bottom: 16px; }

@media (max-width: 560px) {
  .profile-head > :first-child { margin-top: -40px; }
  .profile-head .avatar { width: 84px; height: 84px; font-size: 30px; }
  .profile-head .banner-actions { width: 100%; }
}

/* ---------- Vue 3D d'un badge (js/badge-viewer.js) ---------- */

.ach-open { cursor: pointer; transition: background-color .2s ease, border-color .2s ease; }

.ach-open:hover { background: color-mix(in srgb, var(--text) 4%, transparent); }

.ach-open:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: var(--radius-sm); }

.badge-viewer-open { overflow: hidden; }

.badge-viewer {
  width: min(440px, calc(100vw - 32px));
  max-height: calc(100dvh - 32px);
  padding: 20px 24px 24px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 24px 80px rgba(0, 0, 0, .45);
  text-align: center;
  overflow: auto;
}

.badge-viewer::backdrop {
  background: rgba(0, 0, 0, .62);
  backdrop-filter: blur(6px);
}

.badge-viewer[open] { animation: badge-viewer-in .35s cubic-bezier(.2, .8, .2, 1); }

@keyframes badge-viewer-in {
  from { opacity: 0; transform: translateY(12px) scale(.96); }
}

.badge-viewer-close {
  position: absolute;
  top: 10px;
  right: 12px;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
}

.badge-viewer-close:hover { color: var(--text); background: var(--surface-2); }

.badge-viewer-stage {
  position: relative;
  width: min(340px, 100%);
  aspect-ratio: 1;
  margin: 8px auto 12px;
  /* Le studio du shader est sombre : un fond qui le prolonge, quel que soit le thème. */
  background: radial-gradient(closest-side, rgba(255, 255, 255, .07), transparent);
}

.badge-viewer-canvas {
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  cursor: grab;
}

.badge-viewer-canvas:active { cursor: grabbing; }

.badge-viewer-loading {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 14px;
}

.badge-viewer-fallback { position: absolute; inset: 0; overflow: hidden; touch-action: none; }

.badge-viewer-fallback img {
  height: 100%;
  width: 1700%;
  max-width: none;
  transform: translateX(calc(var(--f, 5) * -100% / 17));
}

.badge-viewer-name { font-size: 20px; margin: 0 0 4px; letter-spacing: -.01em; }

.badge-viewer-desc { margin: 0 0 8px; color: var(--muted); }

.badge-viewer-meta { margin: 0; font-size: 13px; color: var(--muted); }

.badge-viewer-hint { margin: 14px 0 0; font-size: 12px; color: var(--muted); letter-spacing: .04em; text-transform: uppercase; }

/* ---------- Icônes de la suite (img/icons, banque d'icônes des apps) ----------
   Blanches en relief doux : telles quelles en sombre, assombries en clair. */

.ico { width: 20px; height: 20px; display: block; flex: none; object-fit: contain; pointer-events: none; user-select: none; }

:root[data-theme="light"] .ico:not(.ico-color) { filter: brightness(.22) contrast(1.15); }

/* ---------- Menu du compte (js/layout.js + js/account-menu.js) ---------- */

.acct { position: relative; flex: none; }

.acct-trigger {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  cursor: pointer;
  transition: border-color .2s ease, transform .25s cubic-bezier(.2, .8, .2, 1), box-shadow .25s ease;
}

.acct-trigger:hover { border-color: color-mix(in srgb, var(--text) 28%, transparent); }

.acct-trigger:active { transform: scale(.94); }

.acct-trigger:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

.acct.is-open .acct-trigger { box-shadow: 0 0 0 4px color-mix(in srgb, var(--text) 10%, transparent); }

.acct-avatar {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 999px;
  overflow: hidden;
  font-weight: 700;
  font-size: 14px;
  color: var(--text);
  background: var(--surface-2);
  flex: none;
}

.acct-avatar > img:not(.ico) { width: 100%; height: 100%; object-fit: cover; display: block; }

.acct-avatar .ico { width: 18px; height: 18px; }

.acct-trigger .acct-avatar:not([data-member]) { background: transparent; }

.acct-avatar-lg { width: 44px; height: 44px; font-size: 18px; }

.acct-avatar-sm { width: 28px; height: 28px; font-size: 13px; }

.acct-menu {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  z-index: 60;
  width: min(320px, calc(100vw - 24px));
  max-height: calc(100vh - 90px);
  overflow-y: auto;
  padding: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, .28), 0 2px 8px rgba(0, 0, 0, .12);
  transform-origin: top right;
  animation: acct-in .22s cubic-bezier(.2, .8, .2, 1);
}

@keyframes acct-in {
  from { opacity: 0; transform: translateY(-6px) scale(.97); }
  to { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) { .acct-menu { animation: none; } }

.acct-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px;
  border-radius: 12px;
  text-decoration: none;
  transition: background-color .15s ease;
}

.acct-head:hover, .acct-head:focus-visible { background: var(--surface-2); outline: none; }

.acct-names { display: flex; flex-direction: column; min-width: 0; text-align: left; }

.acct-name { font-weight: 600; font-size: 15px; margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.acct-handle { color: var(--muted); font-size: 13px; margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.acct-level {
  margin: 4px 2px 6px;
  padding: 12px;
  border-radius: 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
}

.acct-level-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 14px; }

.acct-level-num, .acct-elan { display: inline-flex; align-items: center; gap: 6px; }

.acct-level-num .ico, .acct-elan .ico { width: 18px; height: 18px; }

.acct-level-num strong { font-size: 16px; margin-left: -2px; }

.acct-elan { color: var(--muted); }

.acct-elan strong { color: var(--text); font-variant-numeric: tabular-nums; }

.acct-bar {
  position: relative;
  height: 6px;
  margin: 10px 0 8px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--text) 10%, transparent);
  overflow: hidden;
}

.acct-bar-fill {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, #FFA97A, #9B8CF0);
  transform-origin: left;
  transform: scaleX(var(--p, 0));
  transition: transform .8s cubic-bezier(.2, .8, .2, 1);
}

.acct-level-hint { margin: 0; color: var(--muted); font-size: 12px; }

.acct-section { padding: 4px 0; border-top: 1px solid var(--border); margin-top: 4px; }

.acct-head + .acct-level + .acct-section { border-top: 0; }

.acct-section-title {
  margin: 6px 10px 4px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
}

.acct-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 9px 10px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 14px;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
  transition: background-color .15s ease;
}

.acct-item:hover, .acct-item:focus-visible { background: var(--surface-2); outline: none; }

.acct-item:disabled { opacity: .5; cursor: progress; }

.acct-item .ico { opacity: .9; }

.acct-item-extra { margin-left: auto; color: var(--muted); font-size: 12px; }

.acct-danger { color: var(--danger); }

.acct-other { display: flex; align-items: center; gap: 2px; }

.acct-other .acct-item { flex: 1; min-width: 0; }

.acct-forget {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  cursor: pointer;
  opacity: .55;
  transition: opacity .15s ease, background-color .15s ease;
}

.acct-forget .ico { width: 14px; height: 14px; }

.acct-forget:hover, .acct-forget:focus-visible { opacity: 1; background: var(--surface-2); outline: none; }

.acct-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 6px 10px; font-size: 14px; }

.acct-intro { padding: 12px 10px 10px; }

.acct-intro .acct-handle { white-space: normal; margin-top: 4px; line-height: 1.45; }

.acct-cta { display: flex; gap: 8px; margin-top: 14px; }

.acct-cta .btn { flex: 1; justify-content: center; text-align: center; }

.acct-flash { margin: 4px 4px 8px; padding: 8px 10px; border-radius: 10px; font-size: 13px; background: var(--danger-bg); color: var(--danger); }

/* Bouton lune / soleil : un interrupteur, deux icônes, un curseur. */

.theme-switch {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  width: 68px;
  height: 34px;
  padding: 0 7px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg);
  cursor: pointer;
  flex: none;
}

.theme-switch:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

.theme-switch .ico { position: relative; z-index: 1; width: 20px; height: 20px; transition: opacity .25s ease, transform .35s cubic-bezier(.2, .8, .2, 1); }

.theme-switch-knob {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 26px;
  height: 26px;
  border-radius: 999px;
  background: var(--surface-2);
  box-shadow: 0 0 0 1px var(--border), 0 2px 6px rgba(0, 0, 0, .25);
  transition: transform .35s cubic-bezier(.2, .8, .2, 1);
}

.theme-switch[data-mode="light"] .theme-switch-knob { transform: translateX(34px); }

.theme-switch[data-mode="dark"] .theme-switch-sun,
.theme-switch[data-mode="light"] .theme-switch-moon { opacity: .35; transform: scale(.85); }

@media (max-width: 720px) {
  .acct { margin-left: auto; }
  .acct-menu { position: fixed; top: 64px; right: 12px; }
}

/* ---------- Pastilles « du nouveau » (js/notifs.js) ----------
   Un point rouge FIXE : jamais de pulsation (règle du projet). */

:root { --notif: #ef4444; }

.site-nav a[data-dot], .acct-trigger[data-dot] { position: relative; }

.site-nav a[data-dot]::after {
  content: "";
  position: absolute;
  top: 3px;
  right: 2px;
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: var(--notif);
  box-shadow: 0 0 0 2px var(--bg);
}

.acct-trigger[data-dot]::after {
  content: "";
  position: absolute;
  top: -1px;
  right: -1px;
  width: 11px;
  height: 11px;
  border-radius: 999px;
  background: var(--notif);
  box-shadow: 0 0 0 2px var(--bg);
}

.notif-pill {
  min-width: 20px;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--notif);
  color: #fff !important;
  font-weight: 700;
  font-size: 11px !important;
  line-height: 18px;
  text-align: center;
  white-space: nowrap;
  max-width: 150px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.notif-dot-inline { margin-left: auto; width: 8px; height: 8px; border-radius: 999px; background: var(--notif); flex: none; }

.friend-tab-n[data-n="incoming"] { background: var(--notif); color: #fff; }

/* Article pas encore lu dans /news */
.nw-unread-dot { width: 8px; height: 8px; border-radius: 999px; background: var(--notif); box-shadow: 0 0 0 3px color-mix(in srgb, var(--notif) 22%, transparent); flex: none; }

/* Menu du compte : « Mes apps » (version web ouvrable, ou bientôt) */
.acct-app-icon { width: 22px; height: 22px; border-radius: 6px; flex: none; display: block; }

.acct-app-tag {
  margin-left: auto;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  background: var(--accent);
  color: var(--accent-text);
}

.acct-app.is-soon { cursor: default; color: var(--muted); }

.acct-app.is-soon:hover { background: transparent; }

.acct-app.is-soon .acct-app-icon { opacity: .55; filter: grayscale(.4); }

.acct-app-dot { margin-left: 8px; }

/* Menu du compte : niveau sur l'XP, élan affiché à part (un score) */
.acct-xp { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }

.acct-xp strong { color: var(--text); }

.acct-level-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; }

.acct-level-foot .acct-elan { font-size: 13px; }

.acct-level-foot .acct-elan .ico { width: 16px; height: 16px; }

.acct-bar-fill { background: linear-gradient(90deg, #8b80ff, #6c63ff); }

/* ---------- Profil : progression, bio, liens (js/profile-extras.js) ---------- */

.pg { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 12px; }

.pg-cell {
  position: relative;
  display: grid;
  align-content: start;
  gap: 12px;
  padding: 16px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface-2);
  overflow: hidden;
}

/* Une lueur discrète, violette pour l'XP, ambrée pour l'élan : décor seul. */
.pg-cell::before {
  content: "";
  position: absolute;
  inset: -40% auto auto -20%;
  width: 70%;
  aspect-ratio: 1;
  border-radius: 50%;
  background: radial-gradient(circle, var(--pg-glow) 0%, transparent 65%);
  opacity: .22;
  pointer-events: none;
}

.pg-level { --pg-glow: #7c6cff; }
.pg-elan { --pg-glow: #ffb347; }

.pg-head { position: relative; display: flex; align-items: center; gap: 12px; }

.pg-icon {
  display: grid;
  place-items: center;
  flex: none;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: color-mix(in srgb, var(--pg-glow) 16%, transparent);
}

.pg-icon .ico { width: 28px; height: 28px; object-fit: contain; }

.pg-text { display: grid; gap: 0; min-width: 0; }

.pg-label { color: var(--muted); font-size: 12px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; }

.pg-value { font-size: 30px; font-weight: 700; letter-spacing: -.03em; line-height: 1.1; font-variant-numeric: tabular-nums; }

.pg-bar {
  position: relative;
  height: 8px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--text) 10%, transparent);
  overflow: hidden;
}

.pg-bar span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #8b80ff, #6c63ff);
  transform-origin: left;
  transform: scaleX(0);
  transition: transform 1.1s cubic-bezier(.2, .8, .2, 1) .15s;
}

.pg.is-in .pg-bar span { transform: scaleX(var(--p)); }

.pg-note { position: relative; margin: 0; color: var(--muted); font-size: 13px; line-height: 1.45; }

.pg-note strong { color: var(--text); font-variant-numeric: tabular-nums; }

.pg-card { padding: 12px; }

.pg-inline { margin: 0 8px 20px; }

@media (max-width: 560px) {
  .pg { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  .pg-bar span { transition: none; }
}

/* Bio et liens, sous l'identité du profil public */
.about { width: 100%; max-width: 520px; margin: -6px auto 20px; display: grid; gap: 14px; justify-items: center; }

.about-bio { margin: 0; white-space: pre-line; line-height: 1.55; overflow-wrap: anywhere; }

.about-links { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }

.about-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  padding: 6px 12px 6px 9px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-size: 13px;
  text-decoration: none;
  transition: border-color .2s ease, transform .2s ease;
}

.about-link:hover { border-color: color-mix(in srgb, var(--text) 28%, transparent); transform: translateY(-1px); }

.about-link .ico { width: 15px; height: 15px; opacity: .8; }

.about-link span { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }

/* Édition de la bio et des liens (compte.html) */
.links-editor { display: grid; gap: 8px; }

.links-editor:empty { display: none; }

.links-row { display: flex; gap: 8px; align-items: center; }

.links-row .input { flex: 1; min-width: 0; }

.links-add { margin-top: 8px; font-size: 14px; }

.links-add[hidden] { display: none; }

@media (min-width: 1100px) {
  .profile-form .profile-form-save { grid-column: 3; grid-row: 1; }
}
