/* Ardinum — connexion et tableau de bord privé. Style « accent ladder » (taste-skill --app, seed 1095138236) :
   une seule teinte, le bleu de la mer de Fish Rush, pleine sur les petites marques (barres, lien actif), pâle sur les surfaces. */
@font-face { font-family: "Fredoka"; src: url("/fonts/fredoka-latin.woff2") format("woff2"); font-weight: 300 700; font-display: swap; }
@font-face { font-family: "Nunito"; src: url("/fonts/nunito-latin.woff2") format("woff2"); font-weight: 200 1000; font-display: swap; }

:root {
  color-scheme: light dark;
  --ground: #f5f9fb; --surface: #ffffff; --raised: #f0f5f8; --active: #dff1fa;
  --border: #e3e9ed; --rule: #eef2f4; --control: #c9d3da;
  --text: #121417; --muted: #59636b; --faint: #66707a;
  --accent: #0f7fb5; --accent-ink: #0b5a80; --accent-pale: #cfeaf7;
  --primary: #121417; --on-primary: #ffffff;
  --warn-bg: #fff4e5; --warn-border: #f5c98a; --warn-ink: #8a3d00;
  --neg: #c4242a;
  --radius-card: 16px; --radius-control: 999px;
  --gap: 16px; --pad: 20px;
  --font: "Nunito", system-ui, sans-serif;
  --brand: "Fredoka", "Nunito", system-ui, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --ground: #0d0d0d; --surface: #161616; --raised: #1f1f1f; --active: #12303d;
    --border: #262626; --rule: #202020; --control: #474747;
    --text: #f4f4f4; --muted: #b4b4b4; --faint: #949494;
    --accent: #5cc6f2; --accent-ink: #9edcf7; --accent-pale: #143746;
    --primary: #f4f4f4; --on-primary: #111111;
    --warn-bg: #2b1f10; --warn-border: #6b4a1c; --warn-ink: #ffc98a;
    --neg: #ff7b7f;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--ground); color: var(--text); font: 400 15px/1.5 var(--font); -webkit-tap-highlight-color: transparent; }
a { color: var(--accent-ink); }
h1, h2 { margin: 0; }
p { margin: 0; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.num { font-variant-numeric: tabular-nums; text-align: right; }

/* ---------- Connexion ---------- */
.login { min-height: 100svh; display: grid; place-items: center; padding: 24px 16px; }
.login-box { width: min(100%, 400px); background: var(--surface); border: 1px solid var(--border); border-radius: 24px; padding: 32px 28px 28px; }
.brand { display: inline-flex; align-items: center; gap: 10px; font: 700 20px/1 var(--brand); color: var(--text); text-decoration: none; }
.brand img { width: 36px; height: 36px; border-radius: 10px; }
.login h1 { font: 700 24px/1.2 var(--brand); margin: 24px 0 8px; }
.sub { color: var(--muted); }
.sub.small { margin-top: 20px; font-size: 14px; }
.login form { margin-top: 24px; }
.login label { display: block; font-weight: 700; font-size: 14px; margin: 16px 0 8px; }
.login input { width: 100%; min-height: 48px; padding: 10px 14px; border: 1px solid var(--control); border-radius: 12px; background: var(--surface); color: var(--text); font: 600 16px/1.2 var(--font); }
.login input:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--accent); }
.login button { margin-top: 24px; width: 100%; min-height: 52px; border: 0; border-radius: 999px; background: var(--primary); color: var(--on-primary); font: 600 17px/1 var(--brand); cursor: pointer; transition: transform 140ms cubic-bezier(0.23, 1, 0.32, 1), opacity 140ms; }
.login button:active { transform: scale(0.98); }
.err { margin-top: 16px; padding: 10px 14px; border-radius: 12px; background: var(--warn-bg); border: 1px solid var(--warn-border); color: var(--warn-ink); font-size: 14px; font-weight: 600; }

/* ---------- Coquille : barre latérale de 224 px + canevas ---------- */
.app { display: grid; grid-template-columns: 224px minmax(0, 1fr); min-height: 100svh; }
.side { position: sticky; top: 0; height: 100svh; display: flex; flex-direction: column; gap: 24px; padding: 18px 12px; border-right: 1px solid var(--border); }
.side .brand { padding: 4px 8px; }
.side nav { display: grid; gap: 2px; }
.side nav a { display: flex; align-items: center; min-height: 38px; padding: 0 12px; border-radius: 10px; color: var(--muted); font-weight: 700; font-size: 15px; text-decoration: none; transition: background-color 140ms; }
@media (hover: hover) { .side nav a:hover { background: var(--raised); color: var(--text); } }
.side nav a[aria-current="page"] { background: var(--active); color: var(--accent-ink); }
.logout { margin-top: auto; }
.logout button { width: 100%; min-height: 38px; border: 1px solid var(--control); border-radius: 999px; background: transparent; color: var(--text); font: 700 14px/1 var(--font); cursor: pointer; }
@media (hover: hover) { .logout button:hover { background: var(--raised); } }
.logout button:active { transform: scale(0.98); }

.main { min-width: 0; }
.top { height: 56px; display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 0 29px; border-bottom: 1px solid var(--border); color: var(--muted); font-size: 13px; }
.crumb { font-weight: 700; }
.stamp { font-variant-numeric: tabular-nums; }
/* Canevas : 1 colonne fluide, 29 px de chaque côté ; « duo » = 2 × (1fr) + 16 px. */
.canvas { padding: 28px 29px 64px; display: grid; gap: var(--gap); max-width: 1240px; }
.title-row { display: flex; align-items: end; justify-content: space-between; gap: 16px; margin-bottom: 8px; }
.title-row h1 { font: 700 26px/1.15 var(--brand); }
.subline { margin-top: 6px; color: var(--muted); font-size: 15px; }
.subline strong { color: var(--text); }

.warn { padding: 12px 16px; border-radius: 12px; background: var(--warn-bg); border: 1px solid var(--warn-border); color: var(--warn-ink); font-size: 14px; font-weight: 700; }

/* Chiffres clés : un seul conteneur partagé par des filets. */
.kpis { margin: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-card); overflow: hidden; }
.kpis > div { padding: 16px var(--pad); border-left: 1px solid var(--rule); margin-left: -1px; }
.kpis dt { color: var(--muted); font-size: 13px; font-weight: 700; }
.kpis dd { margin: 4px 0 2px; font: 600 26px/1.15 var(--font); text-align: left; letter-spacing: -0.01em; }
.kpis p { color: var(--faint); font-size: 12px; }
.panel .kpis { border: 0; border-radius: 0; border-bottom: 1px solid var(--rule); }

.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-card); overflow: hidden; }
.panel-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding: 16px var(--pad) 10px; }
.panel h2 { font: 700 16px/1.3 var(--font); }
.period { color: var(--faint); font-size: 13px; }
.duo { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 600px), 1fr)); gap: var(--gap); align-items: start; }
.empty { margin: 4px var(--pad) var(--pad); padding: 12px 14px; border: 1px dashed var(--control); border-radius: 8px; color: var(--muted); font-size: 14px; }
.note { color: var(--muted); font-size: 13px; }

/* Barres par jour (HTML, sans script). */
.plot { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 10px; padding: 6px var(--pad) 34px; height: 236px; }
.ticks { display: flex; flex-direction: column; justify-content: space-between; color: var(--faint); font-size: 12px; text-align: right; font-variant-numeric: tabular-nums; margin: -8px 0 -8px; }
.grid { position: relative; display: flex; flex-direction: column; justify-content: space-between; }
.grid > i { display: block; border-top: 1px solid var(--rule); }
.grid > i:last-of-type { border-top: 2px solid var(--control); }
.cols { position: absolute; inset: 0; display: flex; align-items: flex-end; justify-content: center; gap: 3px; }
/* Largeur plafonnée : un seul jour ne fait pas une barre pleine largeur. */
.col { position: relative; flex: 1; max-width: 56px; height: 100%; display: flex; align-items: flex-end; }
.bar { display: block; width: 100%; min-height: 0; background: var(--accent); border-radius: 3px 3px 0 0; transition: opacity 120ms; }
@media (hover: hover) { .col:hover .bar { opacity: 0.7; } }
.x { position: absolute; top: calc(100% + 8px); left: 50%; transform: translateX(-50%); color: var(--faint); font-size: 12px; white-space: nowrap; font-variant-numeric: tabular-nums; }

/* Tableaux : filets, chiffres alignés, total en pied. */
.scroll { overflow-x: auto; }
.scroll:focus-visible { outline-offset: -2px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 0 var(--pad); height: 42px; white-space: nowrap; text-align: left; }
thead th { color: var(--muted); font-weight: 600; font-size: 12px; height: 36px; border-bottom: 1px solid var(--border); }
tbody td { border-bottom: 1px solid var(--rule); }
tbody td:first-child { font-weight: 700; }
tfoot th { font-weight: 800; height: 46px; }
th.num, td.num { text-align: right; font-variant-numeric: tabular-nums; }
tbody tr:last-child td { border-bottom: 1px solid var(--border); }
.id { display: inline-flex; align-items: center; gap: 10px; max-width: 28ch; overflow: hidden; text-overflow: ellipsis; }
.row-icon { width: 24px; height: 24px; border-radius: 6px; flex: none; }

/* Vue d'ensemble. */
.sources { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--gap); }
.sources a { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 12px; height: 100%; padding: 18px var(--pad); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-card); text-decoration: none; color: var(--text); transition: border-color 140ms, transform 140ms; }
@media (hover: hover) { .sources a:hover { border-color: var(--accent); } }
.sources a:active { transform: scale(0.99); }
.src-name { font: 700 17px/1.3 var(--brand); color: var(--accent-ink); }
.src-text { grid-column: 1; color: var(--muted); font-size: 14px; }
.src-go { grid-row: 1 / span 2; grid-column: 2; align-self: center; color: var(--accent); font-weight: 800; }
.game-rows { list-style: none; margin: 0; padding: 0 var(--pad) 12px; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 var(--gap); }
.game-rows li { display: flex; align-items: center; gap: 12px; padding: 10px 0; }
.game-rows img { width: 48px; height: 48px; border-radius: 12px; }
.game-rows div { display: grid; }
.game-rows span { color: var(--muted); font-size: 13px; }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* Téléphone et tablette : la barre latérale devient une barre en haut, la navigation défile dans sa ligne. */
@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .side { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 8px 12px; padding: 10px 16px; border-right: 0; border-bottom: 1px solid var(--border); }
  .side nav { order: 3; flex-basis: 100%; display: flex; flex-wrap: wrap; gap: 4px; }
}
@media (max-width: 600px) {
  .side nav { flex-wrap: nowrap; justify-content: space-between; gap: 0; min-width: 0; overflow-x: auto; scrollbar-width: none; }
  .side nav a { padding: 0 6px; }
  .side nav a .long { display: none; } .side nav a .short { display: inline; }
}
@media (max-width: 900px) {
  .side nav a { flex: none; min-height: 44px; }
  .logout { margin: 0 0 0 auto; }
  .logout button { width: auto; min-height: 44px; padding: 0 16px; }
  .top { height: auto; min-height: 36px; padding: 8px 16px; }
  .crumb { display: none; }
  .canvas { padding: 20px 16px 48px; }
  .sources, .game-rows { grid-template-columns: 1fr; }
}
@media (max-width: 600px) {
  .kpis { grid-template-columns: 1fr 1fr; }
  .kpis > div { border-top: 1px solid var(--rule); margin-top: -1px; }
  .kpis > div:nth-child(odd):last-child { grid-column: 1 / -1; }
  .kpis dd { font-size: 22px; }
  .plot { height: 200px; padding: 6px 16px 34px; }
  .cols { gap: 2px; }
  th, td { padding: 0 12px; }
  th:first-child, td:first-child { position: sticky; left: 0; background: var(--surface); }
}

/* ---------- Vue d'ensemble : graphiques SVG (skill dataviz : palette de référence, emplacements 1 à 3,
   validée « toutes paires » en clair sur #ffffff et en sombre sur #161616 ; le turquoise clair est sous 3:1 → légende + tableau). */
:root { --s1: #2a78d6; --s2: #eb6834; --s3: #1baf7a; --gridline: #eef2f4; }
@media (prefers-color-scheme: dark) { :root { --s1: #3987e5; --s2: #d95926; --s3: #199e70; --gridline: #242424; } }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.neg { color: var(--neg); }
.canvas > .kpis, .canvas > .panel, .canvas > .viz-pair, .canvas > .game-cards { margin-bottom: var(--gap); }
.viz { display: block; width: 100%; height: auto; padding: 0 var(--pad) 8px; overflow: visible; }
.viz .grid { stroke: var(--gridline); stroke-width: 1; }
.viz .zero { stroke: var(--faint); stroke-width: 1; }
.viz .tick { fill: var(--faint); font: 600 11px var(--font); font-variant-numeric: tabular-nums; }
.viz .s1 { fill: var(--s1); } .viz .s2 { fill: var(--s2); } .viz .s3 { fill: var(--s3); }
.viz polyline { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.viz .ink { stroke: var(--text); }
.viz .s1line { stroke: var(--s1); } .viz .s1line-dot { fill: var(--s1); stroke: var(--surface); stroke-width: 2; }
.viz .acc { stroke: var(--accent); } .viz .acc-area { fill: var(--accent); opacity: 0.12; }
.viz .acc-dot { fill: var(--accent); stroke: var(--surface); stroke-width: 2; }
.viz .hit { fill: transparent; }
@media (hover: hover) { .viz .hit:hover { fill: var(--text); opacity: 0.05; } }
.legend { list-style: none; margin: 0; padding: 0 var(--pad) 8px; display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 13px; color: var(--muted); }
.legend li { display: flex; align-items: center; gap: 6px; }
.key { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.key.s1 { background: var(--s1); } .key.s2 { background: var(--s2); } .key.s3 { background: var(--s3); }
.key.ink { height: 2px; border-radius: 1px; background: var(--text); }
.viz-sub { margin: 8px var(--pad) 0; font: 700 13px/1.3 var(--font); color: var(--muted); }
.viz-table { padding: 0 var(--pad) 14px; }
.viz-table summary { cursor: pointer; color: var(--accent-ink); font-size: 13px; font-weight: 700; padding: 4px 0; }
.viz-table table { margin-top: 8px; }
.viz-pair { display: grid; grid-template-columns: 1fr 1fr; gap: var(--gap); }
.game-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: var(--gap); }
.game-card { padding: 16px var(--pad); }
.game-card header { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.game-card header img { border-radius: 10px; }
.game-card dl { margin: 0 0 10px; display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.game-card dt { color: var(--muted); font-size: 12px; font-weight: 700; }
.game-card dd { margin: 2px 0 0; font: 600 18px/1.2 var(--font); text-align: left; }
.spark { display: block; width: 100%; height: 36px; }
.spark polyline { fill: none; stroke: var(--s1); stroke-width: 2; stroke-linejoin: round; vector-effect: non-scaling-stroke; }
.spark-note { color: var(--faint); font-size: 12px; margin-top: 2px; }
.sources-title { font: 700 16px/1.3 var(--font); margin: 8px 0 10px; }
@media (max-width: 900px) { .viz-pair { grid-template-columns: 1fr; } }
.viz-box { overflow-x: auto; }
/* Graphique large sur téléphone : il défile, et s'ouvre sur les jours récents (à droite). */
@media (max-width: 700px) { .viz.wide { width: 720px; max-width: none; direction: ltr; } .viz-box:has(.wide) { direction: rtl; } }
/* Tableaux par jour : 7 jours, le reste au bouton. */
.fold:not(:has(details[open])) tr.old { display: none; }
.side nav .short { display: none; }
.viz-empty { margin: 0 var(--pad) 12px; padding: 28px var(--pad); border: 1px dashed var(--border); border-radius: 12px; color: var(--muted); text-align: center; font-size: 14px; }
.spark-empty { color: var(--muted); font-size: 13px; padding: 10px 0 2px; }

/* ---------- Page pub : une carte par vidéo (vignette en portrait, chiffres, jusqu'où on regarde). */
.ad-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(420px, 100%), 1fr)); gap: var(--gap); margin-bottom: var(--gap); }
.ad-card { display: grid; grid-template-columns: 108px 1fr; gap: 16px; padding: 16px; }
.ad-thumb img, .ad-thumb-empty { display: block; width: 108px; height: 192px; border-radius: 10px; object-fit: cover; background: var(--raised); }
.ad-body h3 { margin: 0 0 10px; font: 700 15px/1.3 var(--font); overflow-wrap: anywhere; }
.ad-stats { margin: 0 0 8px; display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px 12px; }
.ad-stats dt { color: var(--muted); font-size: 12px; font-weight: 700; }
.ad-stats dd { margin: 1px 0 0; font: 600 17px/1.2 var(--font); text-align: left; }
.ad-sub { color: var(--faint); font-size: 12px; margin-bottom: 8px; }
.watch { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.watch li { display: grid; grid-template-columns: 40px 1fr 52px; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); }
.watch-track { height: 8px; border-radius: 4px; background: var(--raised); overflow: hidden; }
.watch-bar { display: block; height: 100%; border-radius: 4px; background: var(--s1); }
.watch-val { text-align: right; }
.note { margin: 0 var(--pad) 12px; color: var(--muted); font-size: 13px; max-width: 80ch; }
@media (max-width: 600px) { .ad-cards { grid-template-columns: 1fr; } .ad-card { grid-template-columns: 84px 1fr; } .ad-thumb img, .ad-thumb-empty { width: 84px; height: 150px; } }

/* Inventaire des assets 3D : filtres en ligne, grille de vignettes, fiche à 4 vues. */
.asset-filters { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px; margin: 0 0 var(--gap); }
.asset-filters label { display: grid; gap: 4px; font-size: 12px; font-weight: 600; color: var(--muted); }
.asset-filters input, .asset-filters select { min-height: 40px; padding: 0 12px; border: 1px solid var(--control); border-radius: 10px; background: var(--surface); color: var(--text); font: inherit; font-size: 14px; max-width: 240px; }
.asset-filters input { width: 240px; }
.btn-filter { min-height: 40px; padding: 0 18px; border: 0; border-radius: var(--radius-control); background: var(--accent); color: #fff; font: inherit; font-weight: 700; cursor: pointer; }
.asset-filters .reset { align-self: flex-end; line-height: 40px; color: var(--accent-ink); font-size: 14px; }
.asset-grid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(168px, 1fr)); gap: 12px; }
.asset-grid a { display: grid; gap: 2px; padding: 8px 8px 12px; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; color: var(--text); text-decoration: none; transition: border-color 160ms ease, transform 160ms ease; }
.asset-grid a:hover { border-color: var(--accent); }
.asset-grid a:active { transform: scale(0.98); }
.asset-grid img, .asset-views img { width: 100%; height: auto; aspect-ratio: 1; border-radius: 10px; background: #dbe2ea; display: block; }
.a-title { font-weight: 700; font-size: 14px; line-height: 1.3; margin-top: 6px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.a-meta { color: var(--muted); font-size: 12px; }
.pager { display: flex; justify-content: space-between; align-items: center; margin: var(--gap) 0; font-size: 14px; }
.pager a { color: var(--accent-ink); font-weight: 700; }
.crumbs { margin: 0 0 var(--gap); font-size: 14px; }
.crumbs a { color: var(--accent-ink); }
.asset-detail { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: var(--gap); align-items: start; }
.asset-views { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.asset-facts { display: grid; gap: 0; margin: 0; padding: 8px var(--pad); }
.asset-facts div { display: flex; justify-content: space-between; gap: 16px; padding: 10px 0; border-bottom: 1px solid var(--rule); font-size: 14px; }
.asset-facts dt { color: var(--muted); }
.asset-facts dd { margin: 0; text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.asset-facts .wide { display: grid; border-bottom: 0; }
.asset-facts .wide dd { text-align: left; font-weight: 400; font-size: 12px; }
/* Sections de /assets (3D, UI, icônes, effets, sons) : onglets, cartes de médias, étiquette de licence. */
.asset-tabs { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 var(--gap); }
.asset-tabs a { padding: 8px 14px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface); color: var(--text); font-size: 14px; font-weight: 600; text-decoration: none; }
.asset-tabs a[aria-current="page"] { background: var(--accent-pale); border-color: var(--accent); color: var(--accent-ink); }
.media-grid li { display: grid; gap: 2px; align-content: start; padding: 8px 8px 10px; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; min-width: 0; }
.media-grid img { width: 100%; height: auto; aspect-ratio: 1; object-fit: contain; image-rendering: pixelated; border-radius: 10px; background: repeating-conic-gradient(#dfe5ec 0 25%, #f3f6f9 0 50%) 0 0 / 16px 16px; }
.sound-grid { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.sound-grid audio { width: 100%; height: 40px; }
.lic { justify-self: start; margin-top: 4px; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 700; background: var(--accent-pale); color: var(--accent-ink); }
.lic-interdit { background: var(--neg); color: var(--surface); }
.lic-a_verifier, .lic-credit { background: var(--warn-bg); color: var(--warn-ink); border: 1px solid var(--warn-border); }
@media (max-width: 900px) { .asset-detail { grid-template-columns: 1fr; } }
@media (max-width: 600px) {
  .asset-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .asset-filters label, .asset-filters input, .asset-filters select { width: 100%; max-width: none; }
  .asset-filters { display: grid; grid-template-columns: 1fr; }
}
