/* ══════════════════════════════════════════════════════════════════
   BÂTISSEUR D'AGENT HERMES EXPERT — moteur de style Viktor Oddy
   Émotion visée : maîtrise silencieuse. Un atelier d'orfèvre, la nuit.
   2 polices · 1 accent · 1 direction de lumière · 1 langage d'animation
   Rythme d'espacement : 8 16 24 32 48 64 96 128
   ══════════════════════════════════════════════════════════════════ */
:root {
  --void: #07080b;            /* le fond du monde */
  --night: #0b0d12;           /* dominante */
  --ash: #12151d;             /* secondaire */
  --ivory: #ece7dd;           /* lumière */
  --shade: rgba(0, 0, 0, .55);/* ombre */
  --gold: #c8a24d;            /* l'unique accent */
  --gold-dim: rgba(200, 162, 77, .16);
  --muted: #8a8f9c;
  --danger: #b8574f;
  --alive: #7ba97c;
  --glass: rgba(255, 255, 255, .035);
  --glass-border: rgba(255, 255, 255, .09);
  --radius: 14px;
  --serif: Georgia, 'Times New Roman', serif;
  --sans: 'Segoe UI', system-ui, -apple-system, sans-serif;
  --slow: cubic-bezier(.22, .8, .3, 1);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: var(--sans);
  background:
    radial-gradient(1200px 700px at 18% -10%, rgba(200, 162, 77, .07), transparent 60%),
    radial-gradient(900px 600px at 85% 110%, rgba(70, 90, 130, .06), transparent 60%),
    var(--void);
  color: var(--ivory);
  line-height: 1.6;
  min-height: 100vh;
  letter-spacing: .01em;
}
::selection { background: var(--gold-dim); color: var(--ivory); }
.boot { padding: 128px 48px; text-align: center; color: var(--muted); font-family: var(--serif); font-style: italic; }

/* Aura du curseur — l'interaction invisible */
#aura {
  position: fixed; inset: 0; pointer-events: none; z-index: 1;
  background: radial-gradient(420px at var(--mx, 50%) var(--my, 30%), rgba(200, 162, 77, .05), transparent 70%);
  transition: opacity 1.2s var(--slow);
}

/* Le monde respire */
@keyframes breathe { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }
@keyframes arrive { from { opacity: 0; transform: translateY(24px); } to { opacity: 1; transform: translateY(0); } }
@keyframes sweep { from { transform: translateX(-120%); } to { transform: translateX(220%); } }
.reveal { animation: arrive .9s var(--slow) both; }
.reveal-slow { animation: arrive 1.4s var(--slow) both; }
.d1 { animation-delay: .15s; } .d2 { animation-delay: .3s; } .d3 { animation-delay: .5s; } .d4 { animation-delay: .7s; }

/* ---------- Typographie ---------- */
h1, h2, .display { font-family: var(--serif); font-weight: 500; letter-spacing: .01em; }
h1 { font-size: clamp(2rem, 5vw, 3.4rem); line-height: 1.15; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.02rem; font-weight: 600; }
.eyebrow {
  font-size: .72rem; letter-spacing: .34em; text-transform: uppercase;
  color: var(--gold); font-family: var(--sans);
}
.muted { color: var(--muted); }
.small { font-size: .86rem; }
a { color: var(--gold); text-decoration: none; }
a:hover { text-decoration: underline; }
code {
  background: rgba(255,255,255,.05); padding: .1em .4em; border-radius: 6px;
  font-size: .86em; color: var(--ivory);
}

/* ---------- Champs ---------- */
input, textarea, select {
  font-family: var(--sans); font-size: .95rem; width: 100%;
  background: rgba(255, 255, 255, .03);
  border: 1px solid var(--glass-border);
  border-radius: 10px; color: var(--ivory);
  padding: 14px 16px;
  transition: border-color .5s var(--slow), background .5s var(--slow), box-shadow .5s var(--slow);
}
textarea { min-height: 130px; resize: vertical; line-height: 1.6; }
input:focus, textarea:focus, select:focus {
  outline: none; border-color: rgba(200, 162, 77, .55);
  background: rgba(255, 255, 255, .05);
  box-shadow: 0 0 0 3px rgba(200, 162, 77, .08), inset 0 1px 0 rgba(255,255,255,.06);
}
input::placeholder, textarea::placeholder { color: rgba(138, 143, 156, .55); }
label { display: block; font-weight: 600; margin: 24px 0 8px; font-size: .9rem; }
.hint { color: var(--muted); font-size: .82rem; margin-top: 6px; }
select { appearance: none; }

/* ---------- Boutons — ils respirent ---------- */
button { font-family: inherit; cursor: pointer; }
.btn {
  display: inline-flex; align-items: center; gap: 8px; position: relative; overflow: hidden;
  background: linear-gradient(160deg, #d4b060, var(--gold));
  color: #17120a; border: none; border-radius: 10px;
  padding: 13px 26px; font-weight: 700; font-size: .92rem; letter-spacing: .02em;
  box-shadow: 0 10px 30px -12px rgba(200, 162, 77, .45), inset 0 1px 0 rgba(255,255,255,.35);
  transition: transform .6s var(--slow), box-shadow .6s var(--slow), filter .6s var(--slow);
}
.btn::after { /* balayage de lumière au survol */
  content: ''; position: absolute; top: 0; bottom: 0; width: 40%;
  background: linear-gradient(100deg, transparent, rgba(255,255,255,.35), transparent);
  transform: translateX(-120%);
}
.btn:hover { transform: translateY(-2px); box-shadow: 0 16px 40px -12px rgba(200, 162, 77, .55), inset 0 1px 0 rgba(255,255,255,.35); }
.btn:hover::after { animation: sweep 1.1s var(--slow); }
.btn.secondary {
  background: var(--glass); color: var(--ivory);
  border: 1px solid var(--glass-border); box-shadow: inset 0 1px 0 rgba(255,255,255,.05);
  backdrop-filter: blur(14px);
}
.btn.secondary:hover { border-color: rgba(200, 162, 77, .4); }
.btn.ghost { background: transparent; color: var(--muted); border: 1px dashed var(--glass-border); box-shadow: none; }
.btn.ghost:hover { color: var(--gold); border-color: rgba(200, 162, 77, .45); }
.btn.danger { background: transparent; color: var(--danger); border: 1px solid rgba(184, 87, 79, .5); box-shadow: none; }
.btn.small { padding: 8px 14px; font-size: .8rem; }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }

/* ---------- Verre ---------- */
.card, .panel, .item, pre.snippet {
  background: var(--glass);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  backdrop-filter: blur(18px);
  box-shadow:
    0 30px 60px -30px var(--shade),
    inset 0 1px 0 rgba(255, 255, 255, .07);
}

/* ---------- Barre haute ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 32px; position: sticky; top: 0; z-index: 10;
  background: rgba(7, 8, 11, .7); backdrop-filter: blur(18px);
  border-bottom: 1px solid var(--glass-border);
}
.topbar .brand { font-family: var(--serif); font-size: 1.05rem; color: var(--ivory); cursor: pointer; }
.topbar .brand .glyph { color: var(--gold); margin-right: 10px; }
.topbar .brand small { color: var(--muted); font-family: var(--sans); font-size: .74rem; margin-left: 12px; letter-spacing: .18em; text-transform: uppercase; }
.topbar .who { color: var(--muted); font-size: .85rem; display: flex; gap: 16px; align-items: center; }

/* ---------- Scène d'arrivée ---------- */
.arrival {
  min-height: 100vh; display: flex; flex-direction: column;
  align-items: center; justify-content: center; text-align: center;
  padding: 48px 24px; position: relative; z-index: 2;
}
.arrival .glyph {
  font-size: 3.6rem; color: var(--gold);
  animation: breathe 7s ease-in-out infinite;
  text-shadow: 0 0 60px rgba(200, 162, 77, .35);
}
.arrival h1 { margin: 24px 0 16px; max-width: 17ch; }
.arrival .lead { color: var(--muted); max-width: 52ch; font-size: 1.02rem; margin-bottom: 48px; }
.auth-card { width: min(420px, 92vw); padding: 32px; text-align: left; }
.tabs { display: flex; gap: 8px; margin-bottom: 16px; }
.tabs button {
  flex: 1; background: transparent; border: 1px solid var(--glass-border);
  color: var(--muted); padding: 11px; border-radius: 10px; font-weight: 600; font-size: .88rem;
  transition: all .5s var(--slow);
}
.tabs button.active { background: var(--gold-dim); color: var(--gold); border-color: rgba(200, 162, 77, .5); }
.form-error { color: var(--danger); font-size: .86rem; margin-top: 16px; min-height: 1.2em; }

/* ---------- Pages ---------- */
.page { max-width: 1080px; margin: 0 auto; padding: 48px 32px 128px; position: relative; z-index: 2; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; flex-wrap: wrap; gap: 24px; margin-bottom: 48px; }
.page-head p { color: var(--muted); font-size: .92rem; max-width: 60ch; margin-top: 8px; }

.kit-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 24px; }
.kit-card {
  padding: 28px; cursor: pointer; display: flex; flex-direction: column; gap: 12px;
  transition: transform .7s var(--slow), border-color .7s var(--slow);
}
.kit-card:hover { transform: translateY(-4px); border-color: rgba(200, 162, 77, .45); }
.kit-card h3 { font-family: var(--serif); font-size: 1.15rem; font-weight: 500; }
.kit-card .subject { color: var(--muted); font-size: .86rem; }
.kit-card .meta { display: flex; justify-content: space-between; align-items: center; margin-top: auto; padding-top: 16px; font-size: .78rem; color: var(--muted); }
.badge { padding: 3px 12px; border-radius: 99px; font-size: .72rem; font-weight: 700; letter-spacing: .06em; }
.badge.draft { background: rgba(138, 143, 156, .12); color: var(--muted); }
.badge.published { background: rgba(123, 169, 124, .14); color: var(--alive); }
.empty { text-align: center; color: var(--muted); padding: 96px 24px; border: 1px dashed var(--glass-border); border-radius: var(--radius); }

/* ---------- Bâtisseur : chapitres ---------- */
.builder { display: grid; grid-template-columns: 260px 1fr; gap: 32px; max-width: 1180px; margin: 0 auto; padding: 48px 32px 128px; position: relative; z-index: 2; }
@media (max-width: 900px) { .builder { grid-template-columns: 1fr; } }
.steps { position: sticky; top: 88px; align-self: start; display: flex; flex-direction: column; gap: 4px; }
.step-link {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  background: transparent; border: 1px solid transparent; border-radius: 10px;
  color: var(--muted); padding: 11px 14px; font-size: .88rem;
  transition: all .5s var(--slow);
}
.step-link:hover { background: var(--glass); }
.step-link.active { background: var(--gold-dim); color: var(--gold); border-color: rgba(200, 162, 77, .35); }
.step-link .num {
  font-family: var(--serif); font-size: .8rem; width: 26px; height: 26px; flex-shrink: 0;
  border: 1px solid var(--glass-border); border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  transition: all .5s var(--slow);
}
.step-link.active .num { border-color: var(--gold); color: var(--gold); }
.step-link.done .num { border-color: var(--alive); color: var(--alive); }
.save-state { color: var(--muted); font-size: .74rem; padding: 16px 14px; letter-spacing: .04em; }

.panel { padding: 40px; animation: arrive .8s var(--slow) both; }
.panel .chapter { margin-bottom: 4px; }
.panel h2 { margin-bottom: 6px; }
.panel .lead { color: var(--muted); font-size: .92rem; margin-bottom: 24px; max-width: 64ch; }
.panel-nav { display: flex; justify-content: space-between; margin-top: 48px; }

.coach {
  background: var(--gold-dim); border: 1px solid rgba(200, 162, 77, .3);
  border-radius: 12px; padding: 16px 20px; font-size: .86rem; margin: 16px 0 24px;
}
.coach b { color: var(--gold); }

.item-list { display: flex; flex-direction: column; gap: 12px; margin-top: 16px; }
.item { padding: 16px 20px; border-radius: 12px; transition: border-color .6s var(--slow); }
.item:hover { border-color: rgba(200, 162, 77, .3); }
.item .item-head { display: flex; justify-content: space-between; align-items: baseline; gap: 16px; }
.item .item-head h4 { font-size: .95rem; font-weight: 600; }
.item .desc { color: var(--muted); font-size: .84rem; margin-top: 4px; }
.item .actions { display: flex; gap: 8px; flex-shrink: 0; }

.row { display: grid; grid-template-columns: 1fr 1fr; gap: 0 24px; }
@media (max-width: 640px) { .row { grid-template-columns: 1fr; } }

pre.snippet {
  background: rgba(0, 0, 0, .45); padding: 18px 20px; overflow-x: auto;
  font-size: .82rem; line-height: 1.55; white-space: pre-wrap; word-break: break-all;
  border-radius: 12px; backdrop-filter: none;
}
.snippet-box { position: relative; margin: 8px 0 24px; }
.copy-btn {
  position: absolute; top: 10px; right: 10px;
  background: rgba(255,255,255,.06); color: var(--muted); border: 1px solid var(--glass-border);
  border-radius: 8px; padding: 5px 12px; font-size: .72rem; letter-spacing: .04em;
  transition: all .5s var(--slow); backdrop-filter: blur(8px);
}
.copy-btn:hover { color: var(--gold); border-color: rgba(200, 162, 77, .5); }

.check { display: flex; gap: 12px; align-items: baseline; padding: 5px 0; font-size: .9rem; }
.check .ok { color: var(--alive); }
.check .ko { color: var(--danger); }

.token-reveal {
  background: rgba(123, 169, 124, .08); border: 1px solid rgba(123, 169, 124, .4);
  border-radius: 12px; padding: 20px; margin: 16px 0; word-break: break-all;
  font-family: monospace; font-size: .88rem;
}

/* ---------- La Forge — machine à états ---------- */
.forge-stages { display: flex; flex-direction: column; gap: 12px; margin: 24px 0; }
.stage {
  display: flex; align-items: center; gap: 16px; padding: 16px 20px;
  border: 1px solid var(--glass-border); border-radius: 12px; background: var(--glass);
  transition: all .8s var(--slow);
}
.stage .lamp {
  width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0;
  background: rgba(138,143,156,.35); transition: all .8s var(--slow);
}
.stage.running { border-color: rgba(200, 162, 77, .5); }
.stage.running .lamp { background: var(--gold); box-shadow: 0 0 18px rgba(200,162,77,.8); animation: breathe 1.6s ease-in-out infinite; }
.stage.done { border-color: rgba(123, 169, 124, .4); }
.stage.done .lamp { background: var(--alive); box-shadow: 0 0 10px rgba(123,169,124,.6); }
.stage.failed { border-color: rgba(184, 87, 79, .5); }
.stage.failed .lamp { background: var(--danger); }
.stage .stage-name { font-weight: 600; font-size: .92rem; }
.stage .stage-info { color: var(--muted); font-size: .8rem; margin-left: auto; text-align: right; }

/* ---------- Console Admin ---------- */
.role-card { padding: 28px; margin-bottom: 24px; }
.role-card h3 { font-family: var(--serif); font-weight: 500; font-size: 1.1rem; }
.role-card .role-sub { color: var(--muted); font-size: .84rem; margin: 4px 0 8px; }
.status-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 8px; }
.status-dot.on { background: var(--alive); box-shadow: 0 0 8px rgba(123,169,124,.6); }
.status-dot.off { background: rgba(138,143,156,.4); }

#toast {
  position: fixed; bottom: 32px; left: 50%; transform: translateX(-50%) translateY(8px);
  background: rgba(11, 13, 18, .92); color: var(--ivory);
  border: 1px solid var(--glass-border); backdrop-filter: blur(18px);
  border-radius: 12px; padding: 13px 24px; font-size: .88rem;
  opacity: 0; pointer-events: none; transition: opacity .6s var(--slow), transform .6s var(--slow);
  z-index: 100; max-width: 90vw;
  box-shadow: 0 30px 60px -30px var(--shade);
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.error { border-color: rgba(184, 87, 79, .5); color: #d99a94; }

.divider { border: none; border-top: 1px solid var(--glass-border); margin: 32px 0; }

/* ---------- Les Coulisses (console Admin v3) ---------- */
.admin-tabs { display: flex; gap: 8px; margin-bottom: 32px; flex-wrap: wrap; }
.admin-tab {
  background: transparent; border: 1px solid var(--glass-border); color: var(--muted);
  padding: 10px 22px; border-radius: 99px; font-size: .86rem; font-weight: 600;
  transition: all .5s var(--slow);
}
.admin-tab:hover { color: var(--ivory); border-color: rgba(200, 162, 77, .35); }
.admin-tab.active { background: var(--gold-dim); color: var(--gold); border-color: rgba(200, 162, 77, .5); }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 16px; }
.stat-tile {
  padding: 20px; background: var(--glass); border: 1px solid var(--glass-border);
  border-radius: 12px; backdrop-filter: blur(14px);
  transition: border-color .7s var(--slow);
}
.stat-tile:hover { border-color: rgba(200, 162, 77, .35); }
.stat-v { font-family: var(--serif); font-size: 1.7rem; color: var(--ivory); line-height: 1.2; }
.stat-l { color: var(--muted); font-size: .74rem; letter-spacing: .08em; text-transform: uppercase; margin-top: 4px; }
.stat-s { color: var(--muted); font-size: .78rem; margin-top: 4px; }

.duo { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; align-items: start; }
@media (max-width: 800px) { .duo { grid-template-columns: 1fr; } }
.inner-card { padding: 22px 26px; }
.inner-card h3 { font-family: var(--serif); font-weight: 500; margin-bottom: 12px; }

.credit-nums { display: flex; gap: 36px; margin: 12px 0 16px; flex-wrap: wrap; }
.credit-bar { height: 6px; border-radius: 99px; background: rgba(255, 255, 255, .07); overflow: hidden; }
.credit-bar div {
  height: 100%; border-radius: 99px;
  background: linear-gradient(90deg, #d4b060, var(--gold));
  transition: width 1.2s var(--slow);
}

.pill {
  display: inline-block; padding: 4px 14px; border-radius: 99px; font-size: .78rem;
  border: 1px solid; margin: 2px 6px 2px 0;
}
.pill.ok { color: var(--alive); border-color: rgba(123, 169, 124, .4); background: rgba(123, 169, 124, .08); }
.pill.warn { color: #d9b060; border-color: rgba(200, 162, 77, .45); background: rgba(200, 162, 77, .08); }
.pill.ko { color: var(--danger); border-color: rgba(184, 87, 79, .45); background: rgba(184, 87, 79, .08); }

.incident { border: 1px solid var(--glass-border); border-radius: 10px; padding: 12px 16px; margin-top: 12px; }

.act-feed { max-height: 340px; overflow-y: auto; margin-top: 8px; padding-right: 8px; }
.act { font-size: .84rem; padding: 7px 0; border-bottom: 1px dashed rgba(255, 255, 255, .05); }
.act-time { color: var(--muted); font-size: .74rem; margin-right: 10px; }
.act-type { color: var(--gold); font-size: .7rem; text-transform: uppercase; letter-spacing: .1em; margin-right: 10px; }

.table { width: 100%; border-collapse: collapse; font-size: .86rem; }
.table th {
  text-align: left; color: var(--muted); font-size: .72rem; text-transform: uppercase;
  letter-spacing: .08em; padding: 16px 12px 8px; font-weight: 600;
}
.table td { padding: 10px 12px; border-top: 1px solid rgba(255, 255, 255, .06); vertical-align: middle; }

/* Bannière d'annonce — la voix de l'administrateur */
.banner {
  display: flex; justify-content: center; align-items: center; gap: 16px;
  padding: 11px 56px 11px 24px; position: relative; z-index: 9;
  font-size: .88rem; border-bottom: 1px solid; backdrop-filter: blur(12px);
  animation: arrive .9s var(--slow) both;
}
.banner.info { background: rgba(200, 162, 77, .12); border-color: rgba(200, 162, 77, .35); color: #e6cf96; }
.banner.warn { background: rgba(205, 140, 60, .14); border-color: rgba(205, 140, 60, .4); color: #e0b184; }
.banner.danger { background: rgba(184, 87, 79, .16); border-color: rgba(184, 87, 79, .5); color: #d99a94; }
.banner button {
  position: absolute; right: 16px; background: none; border: none; color: inherit;
  font-size: 1.15rem; opacity: .6; transition: opacity .4s var(--slow);
}
.banner button:hover { opacity: 1; }

/* ---------- v4 : progression, coffre, forge pédagogique ---------- */
.progress-wrap { padding: 12px 14px 4px; }
.progress-label { color: var(--muted); font-size: .72rem; letter-spacing: .06em; margin-bottom: 6px; }
.progress-bar { height: 5px; border-radius: 99px; background: rgba(255, 255, 255, .07); overflow: hidden; }
.progress-bar div {
  height: 100%; border-radius: 99px;
  background: linear-gradient(90deg, #d4b060, var(--gold));
  transition: width 1.2s var(--slow);
}
.kit-card .progress-bar { margin-top: 4px; }

.file-item { display: flex; align-items: center; gap: 16px; }
.filetype {
  flex-shrink: 0; min-width: 52px; text-align: center;
  font-size: .68rem; font-weight: 700; letter-spacing: .08em;
  color: var(--gold); background: var(--gold-dim);
  border: 1px solid rgba(200, 162, 77, .35); border-radius: 8px;
  padding: 6px 8px;
}
.file-item h4 { font-size: .92rem; font-weight: 600; }

.stage-error {
  color: var(--danger); font-size: .8rem; margin-top: 6px;
  max-width: 60ch; line-height: 1.45;
}
.agent-message-block { margin-top: 8px; }

/* ---------- v6 : la commande (curseur de niveau) ---------- */
.level-picker { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
@media (max-width: 640px) { .level-picker { grid-template-columns: 1fr; } }
.level-opt {
  display: flex; flex-direction: column; gap: 6px; text-align: left;
  background: var(--glass); border: 1px solid var(--glass-border); border-radius: 12px;
  color: var(--ivory); padding: 16px 18px; font-size: .9rem;
  transition: all .5s var(--slow); cursor: pointer;
}
.level-opt span { color: var(--muted); font-size: .78rem; line-height: 1.45; }
.level-opt:hover { border-color: rgba(200, 162, 77, .4); }
.level-opt.active {
  background: var(--gold-dim); border-color: rgba(200, 162, 77, .55);
  box-shadow: 0 0 0 3px rgba(200, 162, 77, .08);
}
.level-opt.active b { color: var(--gold); }
