/* HQ : design system unifie (Geist, pilules, rail flottant, verre) + ambiance BLEUE propre au QG.
   Accent azur electrique #38bdf8 (cyan froid, lumineux, « futuriste ») sur nuit bleu profond #050b1f, bleu royal #1d4ed8
   en secondaire (logo, lueurs). Distinct du bleu royal de la Voix (#3b82f6, plus sature et plus sombre : teinte 217 vs 199)
   et des autres espaces (orange coaching, encre Milinks, turquoise Milinkolife). Contrastes verifies par test. */
@font-face { font-family: "Geist"; src: url("/hq-static/fonts/geist-latin.woff2") format("woff2"); font-weight: 100 900; font-display: swap; }
@font-face { font-family: "Geist Mono"; src: url("/hq-static/fonts/geist-mono-latin.woff2") format("woff2"); font-weight: 100 900; font-display: swap; }

:root, [data-theme="dark"] {
  --bg: #050b1f; --surface: #0b1530; --surface-2: #12204a; --text: #e8f1ff; --muted: #9fb3d6; --line: rgba(148,197,255,.12);
  --accent: #38bdf8; --accent-2: #7dd3fc; --accent-ink: #03142e; --royal: #1d4ed8; --glow: rgba(56,189,248,.45); --ok: #34d399; --warn: #fbbf24; --bad: #f87171;
  --glass: rgba(9,19,44,.72); --shadow: 0 18px 50px rgba(0,4,20,.55); --blur: 18px;
  --r-card: 22px; --r-field: 14px; --r-btn: 999px; --r-rail: 30px; --ease: cubic-bezier(.2,.8,.2,1);
  --f-body: "Geist", system-ui, sans-serif; --f-mono: "Geist Mono", ui-monospace, monospace;
  color-scheme: dark;
}
[data-theme="light"] {
  --bg: #eef6ff; --surface: #ffffff; --surface-2: #e3eefb; --text: #0a1730; --muted: #43597c; --line: rgba(10,40,90,.1);
  --accent: #0369a1; --accent-2: #0284c7; --accent-ink: #ffffff; --royal: #1d4ed8; --glow: rgba(14,165,233,.30); --ok: #047857; --warn: #b45309; --bad: #b91c1c;
  --glass: rgba(255,255,255,.74); --shadow: 0 18px 50px rgba(20,60,130,.14);
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font: 400 15px/1.45 var(--f-body); -webkit-font-smoothing: antialiased; }
body { overflow: hidden; overscroll-behavior: none; }
a { color: inherit; }
button { font: inherit; color: inherit; }
.muted { color: var(--muted); }
.mono { font-family: var(--f-mono); font-variant-numeric: tabular-nums; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
:focus-visible { outline: 2px solid var(--accent-2); outline-offset: 2px; }

/* ---------- pilules ---------- */
.pill { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 18px; border-radius: var(--r-btn);
  border: 1px solid var(--line); background: var(--surface-2); text-decoration: none; cursor: pointer; font-weight: 500; white-space: nowrap; }
.pill-accent { background: var(--accent-2); color: var(--accent-ink); border-color: transparent; box-shadow: 0 0 0 1px rgba(255,255,255,.08) inset, 0 8px 30px color-mix(in srgb, var(--accent) 40%, transparent); }
[data-theme="light"] .pill-accent { background: var(--accent); }
.pill-ghost { background: transparent; }
.pill-sm { min-height: 36px; padding: 0 12px; font-size: 13px; }
.chip { display: inline-flex; align-items: center; gap: 6px; min-height: 30px; padding: 0 11px; border-radius: 999px; border: 1px solid var(--line); font-size: 12.5px; background: var(--surface-2); white-space: nowrap; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); flex: none; }
.dot.ok { background: var(--ok); box-shadow: 0 0 10px var(--ok); } .dot.warn { background: var(--warn); } .dot.bad { background: var(--bad); box-shadow: 0 0 10px var(--bad); }

/* ---------- connexion ---------- */
.login-body { display: grid; place-items: center; overflow: auto; min-height: 100%; padding: 24px; background: radial-gradient(900px 600px at 50% 0%, rgba(56,189,248,.20), transparent 60%), radial-gradient(700px 500px at 50% 110%, rgba(29,78,216,.25), transparent 65%), var(--bg); }
.login-grid { position: fixed; inset: 0; pointer-events: none; opacity: .5;
  background-image: linear-gradient(rgba(56,189,248,.09) 1px, transparent 1px), linear-gradient(90deg, rgba(56,189,248,.09) 1px, transparent 1px);
  background-size: 44px 44px; mask-image: radial-gradient(circle at 50% 40%, #000, transparent 70%); -webkit-mask-image: radial-gradient(circle at 50% 40%, #000, transparent 70%); }
.login-card { position: relative; width: min(400px, 100%); padding: 34px 26px 26px; border-radius: var(--r-card); background: var(--glass); border: 1px solid var(--line);
  backdrop-filter: blur(var(--blur)); -webkit-backdrop-filter: blur(var(--blur)); box-shadow: var(--shadow); text-align: center; display: grid; gap: 12px; }
.login-card h1 { margin: 0; font-size: 34px; letter-spacing: .14em; font-weight: 700; }
.login-card p { margin: 0; }
.login-logo { margin: 0 auto; filter: drop-shadow(0 0 22px var(--glow)); }
.login-form { display: grid; gap: 12px; margin-top: 10px; }
.login-form input[type=password] { min-height: 48px; padding: 0 16px; border-radius: var(--r-field); border: 1px solid var(--line); background: var(--surface); color: var(--text); font-size: 16px; }
.check { display: flex; gap: 8px; align-items: center; justify-content: center; font-size: 13px; color: var(--muted); }
.err { color: var(--bad); }
.ssobox { display: grid; gap: 12px; }

/* ---------- application ---------- */
#app { position: fixed; inset: 0; }
#scene { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; cursor: grab; display: block; }
#scene:active { cursor: grabbing; }
.hud-top { position: absolute; top: max(12px, env(safe-area-inset-top)); left: 12px; right: 12px; display: flex; gap: 10px; align-items: center; z-index: 20; pointer-events: none; }
.hud-top > * { pointer-events: auto; }
.brand { display: flex; align-items: center; gap: 10px; padding: 6px 14px 6px 6px; border-radius: 999px; background: var(--glass); border: 1px solid var(--line);
  backdrop-filter: blur(var(--blur)); -webkit-backdrop-filter: blur(var(--blur)); box-shadow: var(--shadow); }
.brand b { letter-spacing: .14em; font-size: 15px; }
.brand .live { font: 500 11px/1 var(--f-mono); color: var(--muted); display: inline-flex; gap: 6px; align-items: center; }
.counters { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; flex: 1; min-width: 0; padding: 2px; }
.counters::-webkit-scrollbar { display: none; }
.counter { display: flex; flex-direction: column; justify-content: center; padding: 6px 14px; border-radius: 18px; background: var(--glass); border: 1px solid var(--line); min-width: 92px;
  backdrop-filter: blur(var(--blur)); -webkit-backdrop-filter: blur(var(--blur)); }
.counter b { font: 600 18px/1.1 var(--f-mono); font-variant-numeric: tabular-nums; }
.counter span { font-size: 11px; color: var(--muted); white-space: nowrap; }
.tools { display: flex; gap: 6px; padding: 5px; border-radius: 999px; background: var(--glass); border: 1px solid var(--line); backdrop-filter: blur(var(--blur)); -webkit-backdrop-filter: blur(var(--blur)); }
.ico { width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; border: 0; background: transparent; cursor: pointer; color: var(--muted); text-decoration: none; }
.ico:hover, .ico[aria-pressed="true"] { background: var(--surface-2); color: var(--text); }
.ico svg { width: 19px; height: 19px; }

/* rail (bureau) / barre d'onglets (mobile) */
.rail { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); z-index: 20; display: flex; flex-direction: column; gap: 6px; padding: 10px 6px;
  background: var(--glass); border: 1px solid var(--line); border-radius: var(--r-rail); box-shadow: var(--shadow); backdrop-filter: blur(var(--blur)); -webkit-backdrop-filter: blur(var(--blur)); }
.tab { position: relative; display: flex; flex-direction: column; align-items: center; gap: 3px; border: 0; background: none; cursor: pointer; color: var(--muted); padding: 8px 6px; border-radius: 20px; min-width: 64px; font-size: 11px; }
.tab svg { width: 22px; height: 22px; }
.tab[aria-current="page"] { color: var(--text); background: color-mix(in srgb, var(--accent) 18%, transparent); }
.tab[aria-current="page"] svg { color: var(--accent-2); }
.demo-banner { position: absolute; left: 50%; transform: translateX(-50%); top: calc(max(12px, env(safe-area-inset-top)) + 64px); z-index: 19; padding: 8px 16px; border-radius: 999px;
  background: var(--accent-2); color: var(--accent-ink); font-weight: 600; font-size: 13px; box-shadow: 0 8px 30px var(--glow); white-space: nowrap; }
[data-theme="light"] .demo-banner { background: var(--accent); }
.toast { position: absolute; left: 50%; bottom: 110px; transform: translateX(-50%); z-index: 30; padding: 10px 16px; border-radius: 999px; background: var(--text); color: var(--bg); font-size: 13px; }

/* vues HTML (ecosysteme, couverture, journal) */
.view { position: absolute; inset: 0; overflow: auto; padding: calc(max(12px, env(safe-area-inset-top)) + 80px) 18px 120px 104px; z-index: 10; background: var(--bg); }
.view[hidden] { display: none; }
.view h2 { margin: 0 0 4px; font-size: 26px; letter-spacing: -.01em; }
.view .lead { margin: 0 0 18px; color: var(--muted); }
.grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-card); padding: 18px; min-width: 0; }
.card h3 { margin: 0 0 10px; font-size: 15px; display: flex; align-items: center; gap: 8px; }
.row { display: flex; justify-content: space-between; gap: 10px; padding: 7px 0; border-top: 1px solid var(--line); font-size: 13.5px; align-items: center; }
.row:first-of-type { border-top: 0; }
.row > span:first-child { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tag { font-size: 12px; padding: 3px 9px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); }
.tag.miss { border-style: dashed; color: var(--warn); }
.bar { height: 6px; border-radius: 6px; background: var(--surface-2); overflow: hidden; }
.bar i { display: block; height: 100%; border-radius: 6px; background: linear-gradient(90deg, var(--accent), var(--accent-2)); }
#eco-svg { width: 100%; height: min(70vh, 720px); display: block; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-card); }
.eco-flow { stroke-dasharray: 3 9; animation: flow 1.6s linear infinite; }
@keyframes flow { to { stroke-dashoffset: -24; } }
.radar-wrap { display: grid; gap: 18px; grid-template-columns: minmax(280px, 420px) 1fr; align-items: start; }
#radar { width: 100%; height: auto; }
.timeline { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; max-width: 760px; }
.timeline li { display: grid; grid-template-columns: 64px 12px 1fr; gap: 10px; align-items: start; padding: 10px 14px; border-radius: 16px; background: var(--surface); border: 1px solid var(--line); }
.timeline time { font: 500 12px/1.6 var(--f-mono); color: var(--muted); }
.timeline .sw { width: 10px; height: 10px; border-radius: 50%; margin-top: 5px; }

/* panneau lateral (piece ouverte) */
.panel { position: absolute; z-index: 25; top: 12px; right: 12px; bottom: 12px; width: min(420px, calc(100% - 24px)); background: var(--glass); border: 1px solid var(--line);
  border-radius: var(--r-card); box-shadow: var(--shadow); backdrop-filter: blur(24px); -webkit-backdrop-filter: blur(24px); overflow: auto; padding: 20px;
  transform: translateX(110%); transition: transform .38s var(--ease); }
.panel.open { transform: none; }
.panel header { display: flex; gap: 12px; align-items: center; margin-bottom: 14px; }
.panel header h2 { margin: 0; font-size: 20px; }
.panel .swatch { width: 40px; height: 40px; border-radius: 14px; flex: none; box-shadow: 0 0 24px currentColor; }
.panel section { margin-top: 16px; }
.panel h4 { margin: 0 0 8px; font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 600; }
.close { margin-left: auto; }
.agent-card { display: grid; grid-template-columns: 44px 1fr; gap: 10px; align-items: center; padding: 10px; border-radius: 16px; background: var(--surface-2); margin-bottom: 8px; }
.agent-card .av { width: 44px; height: 44px; border-radius: 14px; display: grid; place-items: center; font: 700 14px/1 var(--f-mono); color: #050b1f; box-shadow: 0 0 0 1.5px rgba(224,242,254,.55); }
.xp { font: 500 11px/1 var(--f-mono); color: var(--muted); margin-top: 4px; }
.badges { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; }
.badge { padding: 10px; border-radius: 16px; background: var(--surface-2); border: 1px solid var(--line); font-size: 12.5px; }
.badge b { display: block; font-size: 13px; }
.badge.locked { opacity: .45; filter: grayscale(1); }

@media (max-width: 760px) {
  .rail { left: 10px; right: 10px; top: auto; bottom: max(10px, env(safe-area-inset-bottom)); transform: none; flex-direction: row; justify-content: space-around; padding: 6px; border-radius: 26px; }
  .tab { flex: 1; min-width: 0; }
  .view { padding: calc(max(12px, env(safe-area-inset-top)) + 128px) 14px 110px; }
  .counter { min-width: 78px; padding: 5px 11px; } .counter b { font-size: 16px; }
  .brand b { display: none; } .brand { padding-right: 10px; }
  .hud-top { flex-wrap: wrap; } .counters { order: 3; flex-basis: 100%; }
  .tools { margin-left: auto; gap: 2px; padding: 3px; } .ico { width: 34px; height: 34px; }
  .counter span { font-size: 10.5px; }
  .demo-banner { top: calc(max(12px, env(safe-area-inset-top)) + 122px); }
  .panel { top: auto; left: 8px; right: 8px; width: auto; bottom: 8px; max-height: 72vh; transform: translateY(110%); border-radius: 26px; }
  .panel.open { transform: none; }
  .radar-wrap { grid-template-columns: 1fr; }
  .timeline li { grid-template-columns: 54px 12px 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
}
.small { font-size: 11px; } .small13 { font-size: 13px; } .ml-auto { margin-left: auto; }
.mt6 { margin-top: 6px; } .mt8 { margin-top: 8px; } .mt10 { margin-top: 10px; } .mt12 { margin-top: 12px; } .mt14 { margin-top: 14px; } .mt18 { margin-top: 18px; } .maxw { max-width: 1100px; }
#logo [data-pulse] { transition: opacity .4s; }
#logo[data-live="1"] .lg-glow { animation: lgpulse 1.4s ease-in-out infinite; }
#logo[data-live="1"] .lg-top { animation: lgtop 1.4s ease-in-out infinite; }
@keyframes lgpulse { 50% { opacity: .15; } }
@keyframes lgtop { 50% { opacity: .55; } }
.row > span:last-child { flex: none; max-width: 58%; text-align: right; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
[data-theme="light"] .agent-card .av { box-shadow: 0 0 0 1.5px rgba(10,23,48,.35); }
.timeline .sw, .eco-dot { box-shadow: 0 0 0 1.5px rgba(224,242,254,.5); }
[data-theme="light"] .timeline .sw { box-shadow: 0 0 0 1.5px rgba(10,23,48,.35); }
