*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #16171d;
  --surface: #1a1b21;
  --card: #1c1d24;
  --card-alt: #191a20;
  --card-hover: #21222a;
  --border: #2b2c34;
  --border-soft: #24252c;
  --text: #f0f0f4;
  --muted: #9799a5;
  --blue: #7c9cf0;
  --violet: #a190e8;
  --accent: #e8b04e;
  --accent-soft: rgba(232,176,78,0.12);
  --red: #ea7c7c;
  --green: #7fcf9a;
  --bg-rgb: 22,23,29;
  --card-rgb: 28,29,36;
  --card2-rgb: 25,26,32;
}
[data-theme="light"] {
  --bg: #f6f4ef;
  --surface: #ffffff;
  --card: #ffffff;
  --card-alt: #faf8f3;
  --card-hover: #f1efe8;
  --border: #e3ddd0;
  --border-soft: #ece7db;
  --text: #1a1712;
  --muted: #6b6558;
  --blue: #3a5fc4;
  --violet: #7561c9;
  --accent: #c07f18;
  --accent-soft: rgba(192,127,24,0.10);
  --red: #c24444;
  --green: #3e8f5e;
  --bg-rgb: 246,244,239;
  --card-rgb: 255,255,255;
  --card2-rgb: 250,248,243;
}
html { background: var(--bg); overflow-x: hidden; width: 100%; }
body {
  color: var(--text); font-family: 'Sora', system-ui, sans-serif; min-height: 100vh;
  overflow-x: hidden; width: 100%; max-width: 100vw;
  padding-top: 56px; background: var(--bg);
  -webkit-font-smoothing: antialiased;
  transition: background-color 0.2s, color 0.2s;
}
a { color: var(--blue); text-decoration: none; transition: color 0.15s; }
a:hover { color: var(--violet); }

nav {
  position: fixed; top: 0; left: 0; right: 0; z-index: 100;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 1.75rem; height: 56px; display: flex; align-items: center; gap: 1.5rem;
}
.nav-links { display: flex; gap: 1.4rem; list-style: none; margin-left: 2.25rem; align-items: center; }
.nav-links a {
  font-size: 0.8rem; font-weight: 500; letter-spacing: 0.01em;
  color: var(--muted); text-decoration: none;
  padding-bottom: 3px; border-bottom: 1.5px solid transparent; transition: color 0.15s, border-color 0.15s;
}
.nav-links a:hover { color: var(--text); }
.nav-links a.active { color: var(--text); border-bottom-color: var(--accent); }
.nav-brand {
  font-family: 'Sora', sans-serif; font-weight: 700; font-size: 1.02rem; letter-spacing: -0.01em;
  text-decoration: none; color: var(--text);
  display: inline-flex; align-items: center; gap: 0.1rem;
}
.nav-brand:hover { color: var(--text); }

.theme-toggle {
  display: flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; padding: 0; flex-shrink: 0; margin-left: auto;
  color: var(--muted); background: transparent; border: 1px solid var(--border);
  border-radius: 8px; cursor: pointer; transition: all 0.15s;
}
.theme-toggle:hover { border-color: var(--accent); color: var(--accent); }
.theme-toggle svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 2; }
.theme-toggle .icon-sun { display: none; }
[data-theme="light"] .theme-toggle .icon-moon { display: none; }
[data-theme="light"] .theme-toggle .icon-sun { display: block; }

.hero { max-width: 900px; margin: 0 auto; padding: 2rem 1.75rem 0.5rem; }
.hero h1 {
  font-family: 'Sora', sans-serif; font-weight: 700;
  font-size: clamp(1.5rem, 4vw, 1.9rem); letter-spacing: -0.015em; line-height: 1.15;
  color: var(--text);
}
.container { max-width: 900px; margin: 0 auto; padding: 0.75rem 1.75rem 6rem; }
.section-label {
  font-size: 0.72rem; letter-spacing: 0.06em; text-transform: uppercase; font-weight: 600;
  color: var(--muted); margin-bottom: 1rem;
}

/* Board / table des sujets */
.board {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  margin-bottom: 1rem;
}
.board-table { width: 100%; border-collapse: collapse; }
.board-table thead tr { background: var(--card-alt); }
.board-table th {
  text-align: left; font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--muted); font-weight: 600; padding: 0.7rem 1.1rem; border-bottom: 1px solid var(--border);
}
.board-table th.num { text-align: center; width: 90px; }
.board-table th.last-col { width: 190px; }
.board-table tbody tr { border-bottom: 1px solid var(--border-soft); transition: background 0.12s; }
.board-table tbody tr:last-child { border-bottom: none; }
.board-table tbody tr:nth-child(even) { background: var(--card2, var(--card-alt)); }
.board-table tbody tr:hover { background: var(--card-hover); }
.board-table td { padding: 0.6rem 1.1rem; vertical-align: middle; }
.board-table td.last-col { font-size: 0.78rem; color: var(--muted); line-height: 1.5; }
.board-table td.last-col a, .board-table td.last-col .author-link-wrap { color: var(--muted); font-weight: 500; cursor: pointer; }
.board-table td.last-col a:hover, .board-table td.last-col .author-link-wrap:hover { color: var(--text); }
.last-date { color: var(--accent); font-weight: 500; }
.thread-sub { font-size: 0.78rem; color: var(--muted); margin-top: 0.2rem; }
.pin-icon { margin-right: 0.45rem; vertical-align: -3px; display: inline-flex; }
.pin-icon svg { width: 16px; height: 16px; fill: var(--accent); }
.pin-icon.pin-locked svg { fill: var(--muted); }
.board-table td.num {
  text-align: center; color: var(--muted); font-family: 'IBM Plex Mono', monospace; font-size: 0.82rem;
}

.card {
  background: var(--card);
  border: 1px solid var(--border); border-radius: 10px; padding: 1.25rem 1.4rem; margin-bottom: 0.9rem;
  transition: border-color 0.15s;
}
.card:hover { border-color: var(--border-soft); }
.card-link { text-decoration: none; display: block; }

.thread-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; margin-bottom: 0.3rem; }
.thread-title { font-weight: 600; font-size: 0.98rem; letter-spacing: -0.008em; color: var(--text); line-height: 1.35; }
.thread-meta { font-size: 0.78rem; color: var(--muted); }
.reply-badge {
  font-family: 'IBM Plex Mono', monospace; font-size: 0.7rem; font-weight: 500;
  color: var(--muted); background: transparent; border: 1px solid var(--border);
  border-radius: 6px; padding: 0.2rem 0.55rem; white-space: nowrap; flex-shrink: 0;
}
.lock-badge {
  font-size: 0.66rem; letter-spacing: 0.02em; font-weight: 600;
  color: var(--muted); background: rgba(255,255,255,0.04); border-radius: 5px;
  padding: 0.15rem 0.5rem; margin-left: 0.5rem; text-transform: uppercase;
}
.active-dot {
  display: inline-block; width: 6px; height: 6px; border-radius: 50%;
  background: var(--green); margin: 0 0.35rem; vertical-align: middle;
}
.new-dot {
  display: inline-block; width: 8px; height: 8px; border-radius: 50%;
  background: var(--accent); margin-right: 0.5rem; vertical-align: middle;
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.locked-dot {
  display: inline-block; width: 8px; height: 8px; border-radius: 50%;
  background: var(--muted); margin-right: 0.5rem; vertical-align: middle;
  box-shadow: 0 0 0 3px rgba(255,255,255,0.06);
}

.reactions-bar { display: flex; gap: 0.4rem; margin-top: 0.75rem; flex-wrap: wrap; align-items: center; }
.reaction-btn {
  display: inline-flex; align-items: center; gap: 0.3rem;
  background: transparent; border: 1px solid var(--border); border-radius: 100px;
  padding: 0.3rem 0.6rem; font-size: 0.9rem; cursor: pointer; transition: border-color 0.15s;
}
.reaction-btn:hover { border-color: var(--accent); }
.reaction-btn.active { border-color: var(--accent); background: var(--accent-soft); }
.reaction-btn[disabled] { opacity: 0.45; cursor: not-allowed; }
.reaction-btn[disabled]:hover { border-color: var(--border); }
.reaction-count { font-family: 'IBM Plex Mono', monospace; font-size: 0.68rem; color: var(--muted); }
.reaction-btn.active .reaction-count { color: var(--accent); }

.reaction-picker-wrap { position: relative; }
.reaction-toggle {
  font-family: 'IBM Plex Mono', monospace; font-size: 0.68rem;
  background: none; border: 1px solid var(--border); border-radius: 100px; color: var(--muted);
  padding: 0.3rem 0.7rem; cursor: pointer; transition: border-color 0.15s, color 0.15s;
}
.reaction-toggle:hover { border-color: var(--accent); color: var(--text); }
.reaction-picker {
  display: none; position: absolute; bottom: calc(100% + 8px); left: 0; z-index: 20;
  background: var(--card); border: 1px solid var(--border); border-radius: 100px;
  padding: 0.35rem; gap: 0.15rem; box-shadow: 0 6px 20px rgba(0,0,0,0.25);
}
.reaction-picker.open { display: flex; }
.reaction-picker-btn {
  background: none; border: none; font-size: 1.1rem; cursor: pointer;
  padding: 0.3rem 0.4rem; border-radius: 50%; transition: background 0.15s;
}
.reaction-picker-btn:hover { background: var(--card-alt); }
.reaction-picker-btn.active { background: var(--accent-soft); }
.reaction-picker-btn.exclusive { position: relative; }
.reaction-picker-btn.exclusive::after {
  content: ''; position: absolute; inset: -2px; border-radius: 50%;
  border: 1px solid var(--accent); pointer-events: none; opacity: 0.5;
}

.empty-card { border: 1px dashed var(--border); border-radius: 10px; padding: 1.75rem; text-align: center; color: var(--muted); font-size: 0.82rem; }
.error-card { border: 1px solid rgba(234,124,124,0.35); background: rgba(234,124,124,0.06); color: var(--red); border-radius: 10px; padding: 0.9rem 1.2rem; font-size: 0.85rem; margin-bottom: 1rem; }
.success-card { border: 1px solid rgba(127,207,154,0.35); background: rgba(127,207,154,0.06); color: var(--green); border-radius: 10px; padding: 0.9rem 1.2rem; font-size: 0.85rem; margin-bottom: 1rem; }

button, input, textarea { font-family: inherit; }
.btn {
  font-family: 'Sora', sans-serif; font-size: 0.8rem; font-weight: 600;
  color: var(--text); background: transparent; border: 1px solid var(--border);
  border-radius: 8px; padding: 0.6rem 1.05rem; cursor: pointer; transition: all 0.15s;
}
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--accent); border: none; color: #191a1f; }
.btn-primary:hover { filter: brightness(1.08); color: #191a1f; }
.btn-danger { border-color: rgba(234,124,124,0.4); color: var(--red); }
.btn-danger:hover { background: rgba(234,124,124,0.08); border-color: var(--red); color: var(--red); }

.field { margin-bottom: 1.1rem; }
.field label { display: block; font-size: 0.72rem; font-weight: 600; letter-spacing: 0.02em; text-transform: uppercase; color: var(--muted); margin-bottom: 0.4rem; }
.field input, .field textarea {
  width: 100%; background: var(--card-alt); border: 1px solid var(--border); border-radius: 8px;
  padding: 0.65rem 0.85rem; color: var(--text); font-size: 0.9rem; line-height: 1.5; transition: border-color 0.15s, box-shadow 0.15s;
}
.field input:focus, .field textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.field textarea { resize: vertical; min-height: 100px; }
.field-hint { font-size: 0.75rem; color: var(--muted); margin-top: 0.4rem; }

/* ---------- BBCode toolbar ---------- */
.bbcode-toolbar {
  display: flex; flex-wrap: wrap; gap: 0.3rem;
  margin-bottom: 0.5rem;
}
.bbcode-btn {
  min-width: 30px; height: 30px; padding: 0 0.5rem;
  background: var(--card-alt); border: 1px solid var(--border); border-radius: 6px;
  color: var(--text); font-size: 0.78rem; font-weight: 700; font-family: 'Sora', sans-serif;
  cursor: pointer; transition: all 0.15s; display: flex; align-items: center; justify-content: center;
}
.bbcode-btn:hover { border-color: var(--accent); color: var(--accent); }

.post { border-bottom: 1px solid var(--border-soft); padding: 1.15rem 0; }
.post:last-child { border-bottom: none; }
.post-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 0.5rem; }
.post-author { font-weight: 700; font-size: 0.85rem; color: var(--blue); }
.post-date { font-family: 'IBM Plex Mono', monospace; font-size: 0.68rem; color: var(--muted); }
.post-content { font-size: 0.9rem; line-height: 1.6; white-space: pre-wrap; }
.post-content.deleted { color: var(--muted); font-style: italic; }
.post-actions { margin-top: 0.5rem; }
.report-link { font-size: 0.7rem; color: var(--muted); background: none; border: none; cursor: pointer; text-decoration: underline; padding: 0; }
.report-link:hover { color: var(--red); }

.captcha-box {
  display: flex; align-items: center; gap: 0.85rem;
  background: var(--card-alt); border: 1px solid var(--border); border-radius: 8px;
  padding: 0.75rem 0.9rem;
}
.captcha-question { font-family: 'IBM Plex Mono', monospace; font-size: 0.85rem; color: var(--text); white-space: nowrap; }
.captcha-box input { width: auto; flex: 1; }

.banned-badge {
  font-size: 0.66rem; font-weight: 600;
  color: var(--red); background: rgba(234,124,124,0.1); border-radius: 6px;
  padding: 0.2rem 0.55rem; margin-left: 0.5rem;
}

footer { border-top: 1px solid var(--border); padding: 1.6rem 1.75rem; display: flex; align-items: center; justify-content: center; gap: 0.75rem; }
.footer-text { font-size: 0.76rem; color: var(--muted); }

@media (max-width: 720px) {
  nav { padding: 0 1rem; gap: 0.75rem; height: 52px; }
  .nav-brand { font-size: 0.92rem; flex-shrink: 0; white-space: nowrap; }
  .theme-toggle { flex-shrink: 0; margin-left: auto; }

  .nav-links { display: flex; margin-left: auto; }
  .nav-links li { display: none; }
  .nav-links li:last-child { display: block; }

  body { padding-top: 52px; padding-bottom: 64px; }

  .hero { padding: 1.5rem 1.1rem 1rem; }
  .hero h1 { font-size: clamp(1.25rem, 7vw, 1.6rem); line-height: 1.2; }
  .container { padding: 1.1rem 1.1rem 4rem; }

  .card { padding: 1.05rem 1.1rem; }
  .board-table th, .board-table td { padding: 0.65rem 0.8rem; }
  .board-table th.num, .board-table td.num { display: none; }
  .board-table th.last-col, .board-table td.last-col { display: none; }
  .thread-header { flex-direction: column; gap: 0.4rem; align-items: flex-start; }
  .reply-badge { align-self: flex-start; }
  .thread-title { font-size: 0.9rem; }

  .btn { padding: 0.6rem 0.9rem; font-size: 0.76rem; }
  .field input, .field textarea { font-size: 16px; }

  .post-header { flex-direction: column; align-items: flex-start; gap: 0.2rem; }

  .captcha-box { flex-direction: column; align-items: stretch; gap: 0.6rem; }
  .captcha-box input { flex: none; width: 100%; }

  footer { padding: 1.25rem 1.1rem; flex-wrap: wrap; text-align: center; }
}

@media (max-width: 400px) {
  .nav-brand { font-size: 0.85rem; }
  .hero h1 { font-size: 1.25rem; }
}

/* Barre de navigation mobile façon app */
.bottom-nav { display: none; }
@media (max-width: 720px) {
  .bottom-nav {
    display: flex; position: fixed !important; left: 0; right: 0; top: auto !important; bottom: 0 !important; z-index: 200;
    background: var(--surface);
    border-top: 1px solid var(--border);
    padding: 0.4rem 0.5rem calc(0.4rem + env(safe-area-inset-bottom, 0px));
  }
  .bottom-nav-item {
    flex: 1; display: flex; flex-direction: column; align-items: center; gap: 0.2rem;
    padding: 0.35rem 0.25rem; text-decoration: none; color: var(--muted);
    font-size: 0.62rem; font-weight: 500;
    border-radius: 10px; transition: color 0.15s;
    background: none; border: none; cursor: pointer;
  }
  .bottom-nav-item svg {
    width: 21px; height: 21px; fill: none; stroke: currentColor; stroke-width: 2;
    stroke-linecap: round; stroke-linejoin: round;
  }
  .bottom-nav-item.active { color: var(--accent); }
  .bottom-nav-item span { max-width: 64px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}

/* Système de progression (niveaux, XP, badges) — purement cosmétique */
.level-badge {
  display: inline-flex; align-items: center; gap: 0.3rem;
  font-size: 0.66rem; font-weight: 600; letter-spacing: 0.01em;
  padding: 0.15rem 0.5rem; border-radius: 6px;
  background: rgba(255,255,255,0.05); color: var(--muted);
  white-space: nowrap;
}
.level-badge .lvl-num { font-weight: 700; }

.author-line { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }

.xp-panel {
  background: var(--card); border: 1px solid var(--border); border-radius: 10px;
  padding: 1.05rem 1.2rem; margin-bottom: 1.25rem;
}
.xp-panel-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 0.6rem; }
.xp-panel-title { font-weight: 700; font-size: 0.92rem; }
.xp-panel-sub { font-size: 0.72rem; color: var(--muted); }
.xp-bar-track { width: 100%; height: 6px; border-radius: 100px; background: var(--card-alt); overflow: hidden; }
.xp-bar-fill { height: 100%; border-radius: 100px; background: var(--accent); transition: width 0.4s ease; }

/* Pseudo cliquable et personnalisations débloquées par niveau, en crescendo */
.author-link {
  font-weight: 700; font-size: 0.85rem; color: var(--blue);
  text-decoration: none; border-radius: 4px; padding: 0.05rem 0.15rem; transition: color 0.15s;
}
.author-link:hover { color: var(--violet); text-decoration: underline; }
.author-link-static { cursor: default; }
.author-link-static:hover { color: var(--blue); text-decoration: none; }

/* Niveau 3+ : cadre discret */
.perk-frame { border: 1px solid var(--accent-soft); }

/* Niveau 5+ : couleur accent affirmée sur le pseudo, sans animation */
.perk-gradient { color: var(--accent); }

/* Niveau 6 : petite marque discrète devant le pseudo */
.perk-sparkle { display: inline-block; margin-right: 0.25rem; color: var(--accent); }

#profile-username .author-link { font-size: 1.5rem; }

/* Membres sur l'accueil — grille compacte, pas un tableau qui s'étire */
.members-table {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 0.4rem;
}
.member-row {
  display: flex; align-items: center; gap: 0.35rem;
  background: var(--card); border: 1px solid var(--border); border-radius: 8px;
  padding: 0.45rem 0.65rem; text-decoration: none; font-size: 0.8rem;
  transition: border-color 0.15s;
}
.member-row:hover { border-color: var(--accent); }
.member-row-name { font-weight: 600; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.member-row-level { margin-left: auto; font-family: 'IBM Plex Mono', monospace; font-size: 0.68rem; color: var(--muted); flex-shrink: 0; }

@media (max-width: 600px) {
  .members-table { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); }
}

/* Page de profil */
.profile-stats-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; text-align: center; }
.profile-stat { display: flex; flex-direction: column; gap: 0.2rem; }
.profile-stat-value { font-weight: 700; font-size: 1.35rem; color: var(--text); }
.profile-stat-label { font-size: 0.68rem; letter-spacing: 0.02em; color: var(--muted); text-transform: uppercase; }

@media (max-width: 600px) {
  .profile-stats-grid { grid-template-columns: repeat(3, 1fr); gap: 0.5rem; }
  .profile-stat-value { font-size: 1.1rem; }
}

/* Toast de récompense (XP gagnée) */
.reward-toast {
  position: fixed; left: 50%; bottom: 84px; transform: translateX(-50%) translateY(20px);
  background: var(--accent);
  color: #191a1f; font-size: 0.78rem; font-weight: 600;
  padding: 0.6rem 1.1rem; border-radius: 100px; box-shadow: 0 6px 18px rgba(0,0,0,0.3);
  z-index: 300; opacity: 0; transition: opacity 0.25s, transform 0.25s; pointer-events: none;
  white-space: nowrap;
}
.reward-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
@media (min-width: 721px) {
  .reward-toast { bottom: 28px; }
}
