/* ==========================================================================
   Noctis — système de design « dark fantasy premium »
   ========================================================================== */
:root {
  /* Graphite */
  --ink-0: #0b0c0e;
  --ink-1: #101215;
  --ink-2: #15171a;
  --ink-3: #1b1e22;
  --ink-4: #23262b;
  --ink-5: #2e3238;
  --line: #23262b;
  --line-2: #2f333a;
  --line-gold: rgba(139, 108, 239, .42);

  --text: #e7e9ec;
  --text-2: #c2c7ce;
  --text-3: #8a9099;
  --text-4: #5b616a;

  /* Violet (les anciens noms « gold » sont conservés pour la compatibilité) */
  --gold: #8b6cef;
  --gold-2: #b7a2ff;
  --gold-3: #6a51cf;
  --gold-glow: rgba(139, 108, 239, .18);
  --violet: #8b6cef;
  --violet-2: #b7a2ff;
  --on-violet: #120c22;
  --crimson: #8e2c33;
  --crimson-2: #e0606a;
  --emerald: #3f9a68;
  --emerald-2: #5fc58c;
  --azure: #5d8dbd;

  --r-1: 6px;
  --r-2: 9px;
  --r-3: 12px;
  --r-4: 16px;
  --shadow-1: 0 6px 18px rgba(0, 0, 0, .35);
  --shadow-2: 0 18px 50px rgba(0, 0, 0, .55), 0 0 0 1px rgba(0, 0, 0, .4);
  --shadow-3: 0 30px 90px rgba(0, 0, 0, .7);

  --font-display: "Bricolage Grotesque", "Segoe UI", system-ui, sans-serif;
  --font-ui: "IBM Plex Sans", "Segoe UI", system-ui, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, Consolas, monospace;
  --font-serif: "Alegreya", Georgia, serif;
  --font-sheet: "Cinzel", "Trajan Pro", Georgia, serif;

  --chat-w: 360px;
  --ease: cubic-bezier(.2, .7, .2, 1);
  font-size: calc(16px * var(--ui-scale, 1));
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font: 400 14px/1.45 var(--font-ui);
  color: var(--text);
  background: var(--ink-0);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "cv11", "ss01";
}
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: .25;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 .05 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
::selection { background: rgba(139, 108, 239, .35); }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

* { scrollbar-width: thin; scrollbar-color: var(--ink-5) transparent; }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: var(--ink-5); border-radius: 8px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-track { background: transparent; }

.icon { width: 18px; height: 18px; flex: 0 0 auto; display: block; }
.icon.sm { width: 15px; height: 15px; }
.icon.lg { width: 22px; height: 22px; }

/* ---------- Typographie ---------- */
.eyebrow {
  font: 600 10.5px/1 var(--font-ui);
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--text-3);
}
.display { font-family: var(--font-display); letter-spacing: .04em; }
.muted { color: var(--text-3); }

/* ---------- Boutons ---------- */
a.btn { text-decoration: none; }
.btn {
  height: 36px;
  padding: 0 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: var(--r-2);
  border: 1px solid var(--line-2);
  background: var(--ink-3);
  color: var(--text);
  font-weight: 550;
  font-size: 13px;
  white-space: nowrap;
  transition: border-color .15s, background .15s, color .15s, transform .1s;
}
.btn:hover { border-color: #3d424a; background: var(--ink-4); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary {
  border-color: #8b6cef;
  background: #8b6cef;
  color: #120c22;
  box-shadow: 0 6px 18px rgba(139, 108, 239, .22);
}
.btn.primary:hover { background: #9c80f5; border-color: #9c80f5; }
.btn.danger { color: #f0a3a8; border-color: #5b2b30; background: linear-gradient(180deg, #2a1719, #211315); }
.btn.danger:hover { border-color: #8e3a42; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn.ghost:hover { background: var(--ink-3); color: var(--text); }
.btn.sm { height: 30px; padding: 0 10px; font-size: 12px; border-radius: 7px; }
.btn.lg { height: 44px; padding: 0 20px; font-size: 14px; }
.btn.block { width: 100%; }

.icon-btn {
  width: 34px;
  height: 34px;
  display: inline-grid;
  place-items: center;
  border-radius: var(--r-2);
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-3);
  transition: background .15s, color .15s, border-color .15s;
}
.icon-btn:hover { background: var(--ink-3); color: var(--text); }
.icon-btn.active { color: var(--gold-2); background: var(--gold-glow); border-color: var(--line-gold); }
.icon-btn.sm { width: 28px; height: 28px; border-radius: 6px; }
.icon-btn.sm .icon { width: 15px; height: 15px; }

/* ---------- Champs ---------- */
.field { display: grid; gap: 6px; margin-bottom: 14px; }
.field > span, .field > label { font: 600 10.5px/1 var(--font-ui); letter-spacing: .12em; text-transform: uppercase; color: var(--text-3); }
.input, .field input:not([type=checkbox]):not([type=radio]):not([type=range]):not([type=file]), .field select, .field textarea, .select, .textarea {
  width: 100%;
  height: 38px;
  padding: 0 11px;
  border-radius: var(--r-2);
  border: 1px solid var(--line-2);
  background: var(--ink-1);
  color: var(--text);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.field textarea, .textarea { height: auto; min-height: 90px; padding: 10px 11px; resize: vertical; line-height: 1.5; }
.input:focus, .field input:focus, .field select:focus, .field textarea:focus, .select:focus, .textarea:focus { border-color: var(--gold-3); box-shadow: 0 0 0 3px var(--gold-glow); }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field-row.three { grid-template-columns: repeat(3, 1fr); }
.hint { color: var(--text-3); font-size: 12px; line-height: 1.5; margin: 0; }
.error-text { color: #ec9aa0; font-size: 12.5px; min-height: 18px; margin: 0; }

.check { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--text-2); cursor: pointer; }
.check input { accent-color: var(--gold); width: 16px; height: 16px; }

input[type=range] { accent-color: var(--gold); width: 100%; }

.switch { position: relative; width: 34px; height: 20px; flex: 0 0 auto; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch span { position: absolute; inset: 0; border-radius: 20px; background: var(--ink-5); transition: .2s; }
.switch span::after { content: ""; position: absolute; left: 3px; top: 3px; width: 14px; height: 14px; border-radius: 50%; background: var(--text-2); transition: .2s var(--ease); }
.switch input:checked + span { background: var(--gold-3); }
.switch input:checked + span::after { transform: translateX(14px); background: #fff; }

.segmented { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 3px; padding: 3px; border-radius: var(--r-2); background: var(--ink-1); border: 1px solid var(--line); }
.segmented button { height: 30px; border: 0; border-radius: 6px; background: transparent; color: var(--text-3); font-size: 12px; font-weight: 600; display: flex; align-items: center; justify-content: center; gap: 6px; }
.segmented button:hover { color: var(--text); }
.segmented button.active { background: var(--ink-4); color: var(--gold-2); box-shadow: inset 0 0 0 1px var(--line-gold); }

/* ---------- Badges, puces ---------- */
.badge { display: inline-flex; align-items: center; gap: 5px; height: 20px; padding: 0 8px; border-radius: 20px; font: 600 10px/1 var(--font-ui); letter-spacing: .1em; text-transform: uppercase; border: 1px solid var(--line-2); color: var(--text-2); background: var(--ink-2); }
.badge.gold { color: var(--gold-2); border-color: var(--line-gold); background: rgba(139, 108, 239, .1); }
.badge.crimson { color: #f0a3a8; border-color: rgba(191, 74, 82, .4); background: rgba(142, 44, 51, .15); }
.badge.green { color: #9bdcb2; border-color: rgba(78, 154, 106, .4); background: rgba(78, 154, 106, .12); }

.avatar {
  width: 30px; height: 30px; border-radius: 50%;
  display: grid; place-items: center; flex: 0 0 auto;
  font: 700 11px/1 var(--font-display); letter-spacing: .01em;
  color: var(--text);
  background: var(--ink-4);
  border: 1px solid var(--line-2);
  background-size: cover; background-position: center;
}
.avatar.gm { border-color: var(--violet); color: var(--on-violet); background: var(--violet); }
.avatar.online { box-shadow: 0 0 0 2px var(--ink-1), 0 0 0 3.5px var(--emerald); }

.divider { height: 1px; background: var(--line); margin: 14px 0; }
.ornament { display: flex; align-items: center; gap: 12px; color: var(--gold-3); }
.ornament::before, .ornament::after { content: ""; flex: 1; height: 1px; background: linear-gradient(90deg, transparent, var(--line-gold), transparent); }

.empty-state { display: grid; justify-items: center; gap: 10px; padding: 34px 20px; text-align: center; color: var(--text-3); }
.empty-state .icon { width: 30px; height: 30px; color: var(--gold-3); }
.empty-state strong { color: var(--text-2); font: 700 15px var(--font-display); }
.empty-state p { margin: 0; font-size: 12.5px; line-height: 1.55; max-width: 260px; }

/* ---------- Modales ---------- */
.modal-layer { position: fixed; inset: 0; z-index: 200; display: grid; place-items: center; padding: 20px; background: rgba(5, 4, 3, .72); backdrop-filter: blur(6px); animation: fade .18s ease; }
.modal {
  width: min(480px, 100%);
  max-height: calc(100vh - 40px);
  overflow: auto;
  border-radius: var(--r-4);
  border: 1px solid var(--line-2);
  background: var(--ink-2);
  box-shadow: var(--shadow-3);
  animation: rise .22s var(--ease);
}
.modal.wide { width: min(720px, 100%); }
.modal-head { display: flex; align-items: center; gap: 12px; padding: 18px 20px 14px; border-bottom: 1px solid var(--line); }
.modal-head h2 { margin: 0; font: 700 18px/1.2 var(--font-display); letter-spacing: -.01em; flex: 1; }
.modal-head .icon-mark { width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center; color: var(--gold-2); background: var(--gold-glow); border: 1px solid var(--line-gold); }
.modal-body { padding: 18px 20px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px 18px; border-top: 1px solid var(--line); }
.modal-foot .spacer { flex: 1; }

/* ---------- Menus contextuels ---------- */
.menu { position: fixed; z-index: 260; min-width: 190px; padding: 5px; border-radius: var(--r-3); border: 1px solid var(--line-2); background: var(--ink-3); box-shadow: var(--shadow-2); animation: rise .14s var(--ease); }
.menu button { width: 100%; height: 32px; display: flex; align-items: center; gap: 9px; padding: 0 10px; border: 0; border-radius: 7px; background: transparent; color: var(--text-2); font-size: 13px; text-align: left; }
.menu button:hover { background: var(--ink-4); color: var(--text); }
.menu button.danger { color: #ec9aa0; }
.menu hr { border: 0; height: 1px; background: var(--line); margin: 4px 2px; }

/* ---------- Notifications ---------- */
.toasts { position: fixed; z-index: 300; right: 18px; bottom: 18px; display: grid; gap: 8px; pointer-events: none; }
.toast { display: flex; align-items: center; gap: 10px; min-width: 220px; max-width: 360px; padding: 11px 14px; border-radius: var(--r-3); border: 1px solid var(--line-2); background: rgba(27, 30, 34, .98); box-shadow: var(--shadow-2); font-size: 13px; animation: toast-in .25s var(--ease); }
.toast .icon { color: var(--gold); }
.toast.error .icon { color: var(--crimson-2); }
.toast.out { animation: toast-out .2s ease forwards; }

.tooltip { position: fixed; z-index: 400; pointer-events: none; padding: 6px 9px; border-radius: 6px; background: #08090a; border: 1px solid var(--line-2); color: var(--text); font-size: 12px; box-shadow: var(--shadow-1); white-space: nowrap; animation: fade .12s ease; }
.tooltip kbd { margin-left: 8px; }
kbd { display: inline-block; padding: 1px 5px; border-radius: 4px; border: 1px solid var(--line-2); background: var(--ink-3); font: 600 10px/1.5 var(--font-ui); color: var(--text-2); }

@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { opacity: 0; transform: translateY(8px) scale(.985); } }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px); } }
@keyframes toast-out { to { opacity: 0; transform: translateY(6px); } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 50% { opacity: .45; } }

.src-tag { display: inline-block; margin-left: 6px; font: 600 9.5px/1.4 var(--font-mono); letter-spacing: .02em; color: #e7c77a; border: 1px solid rgba(231, 199, 122, .45); border-radius: 5px; padding: 0 5px; vertical-align: middle; }
.src-tag.srd { color: var(--text-3); border-color: var(--line-2); }
.src-tag.hb { color: var(--violet-2); border-color: rgba(139, 108, 239, .45); }
.srcs .src-tag { margin-left: 0; }
.badge.vtm { color: #f0a0ac; border-color: rgba(217, 65, 90, .5); background: rgba(179, 38, 58, .18); }
.darkpack { display: flex; align-items: center; gap: 12px; margin-top: 18px; padding-top: 12px; border-top: 1px solid var(--line); font-size: 11px; line-height: 1.5; color: var(--text-3); text-align: left; }
.darkpack img { width: 64px; height: auto; flex: 0 0 auto; }
.darkpack p { margin: 0; }
.darkpack strong { color: var(--text-2); font-weight: 600; }
.darkpack.compact { max-width: 720px; margin: 10px auto 0; border-top: 0; justify-content: center; }
.lobby-foot { display: grid; justify-items: center; gap: 6px; }
