:root {
  --bg: #0b0d12; --surface: #10131a; --surface2: #151a22;
  --fg: #e7ece8; --muted: #8e918c; --faint: #5c615c;
  --accent: #d7e3c9; --accent2: #8faf9a; --line: rgba(215,227,201,0.12);
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--fg);
  font-family: ui-sans-serif, system-ui, sans-serif; height: 100%; }
a { color: var(--accent); }

/* ── topbar ── */
.topbar { display: flex; align-items: center; gap: 12px; padding: 10px 18px;
  border-bottom: 1px solid var(--line); position: relative; z-index: 30;
  background: rgba(11,13,18,0.92); backdrop-filter: blur(8px); }
.brand { display: inline-flex; gap: 10px; align-items: center; color: var(--fg);
  text-decoration: none; font-weight: 650; letter-spacing: -0.01em; }
.mark { color: var(--accent); }
.badge { font: 600 0.66rem/1 ui-monospace, monospace; letter-spacing: 0.12em;
  text-transform: uppercase; color: var(--accent); border: 1px solid var(--line);
  padding: 5px 10px; border-radius: 999px; }
.top-links { margin-left: auto; display: flex; gap: 14px; }
.top-links a { color: var(--muted); text-decoration: none; font-size: 0.85rem;
  border-bottom: 1px solid transparent; }
.top-links a:hover { color: var(--fg); border-color: var(--accent); }

/* ── accueil (clair sans graphe) ── */
.home { max-width: 1080px; margin: 0 auto; padding: 56px 22px 40px; }
.home-hero { text-align: left; }
.kicker { font: 600 0.72rem/1.6 ui-monospace, monospace; letter-spacing: 0.22em;
  color: var(--accent2); text-transform: uppercase; margin: 0 0 14px; }
.home h1 { font-size: clamp(1.9rem, 5vw, 3rem); line-height: 1.08; letter-spacing: -0.02em;
  margin: 0 0 16px; font-weight: 700; }
.home h1 em { color: var(--accent); font-style: normal; }
.home .lead { color: var(--muted); font-size: clamp(1rem, 1.4vw, 1.12rem);
  line-height: 1.6; max-width: 62ch; margin: 0 0 26px; }
.repo-form { display: flex; gap: 10px; flex-wrap: wrap; max-width: 720px; }
.repo-form input { flex: 1 1 340px; background: var(--surface); color: var(--fg);
  border: 1px solid var(--line); border-radius: 14px; padding: 15px 18px;
  font-size: 1rem; }
.repo-form input:focus { outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(215,227,201,0.12); }
.btn { border: 0; cursor: pointer; border-radius: 12px; padding: 13px 18px;
  font-weight: 650; font-size: 0.95rem; background: var(--accent); color: var(--bg);
  transition: transform 0.12s var(--ease, ease), opacity 0.12s; }
.btn:hover { transform: translateY(-1px); }
.btn:disabled { opacity: 0.5; cursor: default; transform: none; }
.btn .arrow { display: inline-block; transition: transform 0.15s; }
.btn:hover .arrow { transform: translateX(3px); }
.btn-ghost { background: transparent; color: var(--accent); border: 1px solid var(--line); }
.btn-ghost:hover { border-color: var(--accent); }
.btn-small { padding: 8px 12px; font-size: 0.8rem; border-radius: 10px; }
.quick { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 14px; }
.quick span { color: var(--faint); font-size: 0.85rem; }
.quick button { background: var(--surface2); color: var(--fg); border: 1px solid var(--line);
  border-radius: 999px; padding: 7px 14px; font-size: 0.85rem; font-family: ui-monospace, monospace;
  cursor: pointer; transition: border-color 0.12s, color 0.12s; }
.quick button:hover { border-color: var(--accent); color: var(--accent); }
.hero-note { color: var(--faint); font: 400 0.85rem ui-monospace, monospace; min-height: 1.3em; margin: 12px 0 0; }
.features { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 14px; margin-top: 54px; }
.feature { background: var(--surface); border: 1px solid var(--line);
  border-radius: 18px; padding: 20px; }
.f-ic { font-size: 1.3rem; color: var(--accent); }
.feature h3 { margin: 10px 0 8px; font-size: 1rem; }
.feature p { margin: 0; color: var(--muted); font-size: 0.9rem; line-height: 1.55; }
.feature b { color: var(--fg); }

/* ── scène PLEINE PAGE ── */
.stage { position: fixed; inset: 0; z-index: 10; display: flex;
  background: radial-gradient(120% 100% at 50% -10%, rgba(215,227,201,0.05), transparent 55%), var(--bg); }
.stage[hidden] { display: none; }
.stage-canvas { position: absolute; inset: 0; }
.stage-canvas canvas { display: block; width: 100%; height: 100%; cursor: grab; }
.stage-canvas canvas:active { cursor: grabbing; }
.hud-top { position: absolute; top: 0; left: 0; right: 0; z-index: 12;
  display: flex; justify-content: space-between; align-items: flex-start; gap: 12px;
  padding: 14px 18px; pointer-events: none; }
.hud-id { pointer-events: auto; background: rgba(11,13,18,0.78); backdrop-filter: blur(8px);
  border: 1px solid var(--line); border-radius: 14px; padding: 10px 14px; max-width: 46vw; }
.hud-id h2 { margin: 0; font-size: 1rem; letter-spacing: -0.01em;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hud-id p { margin: 3px 0 0; color: var(--faint); font: 400 0.76rem ui-monospace, monospace;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hud-actions { display: flex; gap: 8px; pointer-events: auto; }
.analysis { position: absolute; left: 18px; bottom: 52px; z-index: 12; max-width: min(560px, calc(100vw - 40px));
  background: rgba(11,13,18,0.72); backdrop-filter: blur(8px); border: 1px solid var(--line);
  border-radius: 12px; padding: 9px 12px; color: var(--accent2);
  font: 400 0.76rem/1.5 ui-monospace, monospace; }
.analysis[hidden] { display: none; }
.hint-stage { position: absolute; right: 18px; bottom: 14px; z-index: 12; color: var(--faint);
  font: 400 0.72rem/1.4 ui-monospace, monospace; pointer-events: none; }
.hint-stage { right: 18px; }

/* ── tiroir chat ── */
.chat-drawer { position: fixed; top: 0; right: 0; bottom: 0; z-index: 20; width: min(440px, 100vw);
  display: flex; flex-direction: column; background: rgba(13,16,22,0.96);
  backdrop-filter: blur(10px); border-left: 1px solid var(--line);
  box-shadow: -18px 0 60px rgba(0,0,0,0.5); padding: 14px 16px 16px; }
.chat-drawer[hidden] { display: none; }
.chat-head { display: flex; justify-content: space-between; align-items: center; gap: 10px;
  padding-bottom: 10px; border-bottom: 1px solid var(--line); }
.chat-head h2 { margin: 0; font-size: 0.98rem; line-height: 1.35; flex: 1 1 auto; min-width: 0; }
.chat-llm { color: var(--faint); font: 400 0.74rem/1.4 ui-monospace, monospace; display: flex;
  align-items: center; gap: 7px; margin-top: 2px; width: 100%; min-width: 0; }
.chat-llm #llm-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.dot { width: 8px; height: 8px; border-radius: 50%; flex: none; display: inline-block;
  background: var(--faint); box-shadow: 0 0 0 0 rgba(0,0,0,0); }
.dot-off { background: #5c615c; }
.dot-ok { background: #7fd493; box-shadow: 0 0 8px rgba(127,212,147,0.7); }
.dot-warn { background: #e6c384; box-shadow: 0 0 8px rgba(230,195,132,0.6); }
.dot-err { background: #e07a6a; box-shadow: 0 0 8px rgba(224,122,106,0.7); }
.chat-head-actions { display: flex; gap: 6px; flex: none; }
.chat-settings { display: grid; gap: 9px; padding: 14px 0; max-height: 52vh; overflow: auto; }
.chat-settings[hidden] { display: none; }
.chat-settings label { display: grid; grid-template-columns: 128px 1fr; gap: 10px; align-items: center;
  font: 500 0.8rem ui-monospace, monospace; color: var(--muted); }
.chat-settings input, .chat-settings select { background: var(--bg); color: var(--fg);
  border: 1px solid var(--line); border-radius: 10px; padding: 9px 11px; font-size: 0.88rem; width: 100%; }
.settings-note { grid-column: 1 / -1; color: var(--faint); font-size: 0.76rem; margin: 2px 0; line-height: 1.5; }
.chat-log { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 10px;
  padding: 12px 2px; }
.chat-msg { max-width: 88%; padding: 10px 13px; border-radius: 14px; font-size: 0.92rem;
  line-height: 1.5; white-space: pre-wrap; }
.chat-user { align-self: flex-end; background: var(--accent); color: var(--bg); }
.chat-ai { align-self: flex-start; background: var(--surface2); border: 1px solid var(--line); }
.chat-meta { font: 600 0.62rem/1.4 ui-monospace, monospace; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--accent2); margin-bottom: 4px; }
.chat-body.live::after { content: "▍"; color: var(--accent); animation: chat-blink 1s steps(2) infinite;
  margin-left: 1px; }
@keyframes chat-blink { 50% { opacity: 0; } }
.chat-err { color: #e8a296; }
.chat-form { display: flex; gap: 8px; }
.chat-form input { flex: 1; background: var(--surface); color: var(--fg);
  border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; font-size: 0.93rem; }
.chat-form input:disabled { opacity: 0.55; }
.chat-form .btn { flex: none; min-width: 96px; }
.chat-form .btn-stop { background: #e07a6a; color: var(--bg); }
.settings-row { grid-column: 1 / -1; display: flex; gap: 8px; flex-wrap: wrap; }
.settings-row .btn { padding: 9px 12px; font-size: 0.8rem; }
#llm-status { grid-column: 1 / -1; min-height: 1.2em; margin-top: 2px; white-space: pre-wrap; }
.wallet-sec { grid-column: 1 / -1; margin-top: 6px; border-top: 1px solid var(--line);
  padding-top: 12px; display: grid; gap: 9px; }
.wallet-title { margin: 0; font: 650 0.7rem/1.4 ui-monospace, monospace; letter-spacing: 0.14em;
  text-transform: uppercase; color: var(--accent); }
.wallet-check { display: flex !important; grid-template-columns: none !important; gap: 10px;
  align-items: center; justify-content: space-between; cursor: pointer; }
.wallet-check input { width: auto; }
.chat-wallet { color: var(--faint); font: 400 0.7rem/1.4 ui-monospace, monospace;
  text-align: right; margin: 0 0 6px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-wallet[hidden] { display: none; }

/* ── petit écran ── */
@media (max-width: 640px) {
  .home { padding: 40px 16px 30px; }
  .features { grid-template-columns: 1fr; margin-top: 36px; }
  .hud-id { max-width: 62vw; }
  .analysis { left: 10px; bottom: 66px; max-width: calc(100vw - 20px); }
  .chat-drawer { width: 100vw; }
  .hint-stage { display: none; }
  }

body.loaded .home { display: none; }
body.loaded .topbar { display: none; }   /* pleine page : le HUD de la scène prend le relais */
body:not(.loaded) .stage { display: none; }
.hud-top { top: 14px; }
