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

:root {
  --bg: #16171d;
  --row: #1c1d24;
  --row-alt: #191a20;
  --row-hover: #21222a;
  --card: #1c1d24;
  --card2: #191a20;
  --surface: #1c1d24;
  --line: #2b2c34;
  --line-soft: #24252c;
  --border: #2b2c34;
  --text: #e4e4ea;
  --muted: #8a8c98;
  --link: #7c9cf0;
  --link-visited: #a190e8;
  --blue: #7c9cf0;
  --violet: #a190e8;
  --accent: #e8b04e;
  --accent-soft: rgba(232,176,78,0.12);
  --glow-blue: rgba(124,156,240,0.14);
  --glow-violet: rgba(161,144,232,0.14);
  --header-bg: #1a1b21;
  --red: #ef8b8b;
  --green: #7bc99a;
  --bg-rgb: 22,23,29;
  --card-rgb: 28,29,36;
  --card2-rgb: 25,26,32;
}

[data-theme="light"] {
  --bg: #f5f5f7;
  --row: #ffffff;
  --row-alt: #fafafb;
  --row-hover: #f0f0f4;
  --card: #ffffff;
  --card2: #fafafb;
  --surface: #ffffff;
  --line: #e4e4ea;
  --line-soft: #ececf0;
  --border: #e4e4ea;
  --text: #1a1b21;
  --muted: #6f7180;
  --link: #4c6fd6;
  --link-visited: #7c5cd6;
  --blue: #4c6fd6;
  --violet: #7c5cd6;
  --accent: #b8791f;
  --accent-soft: rgba(184,121,31,0.10);
  --glow-blue: rgba(76,111,214,0.08);
  --glow-violet: rgba(124,92,214,0.08);
  --header-bg: #ffffff;
  --red: #c94f4f;
  --green: #3f9464;
  --bg-rgb: 245,245,247;
  --card-rgb: 255,255,255;
  --card2-rgb: 250,250,251;
}

html { background: var(--bg); overflow-x: hidden; width: 100%; }
body {
  color: var(--text);
  font-family: 'Sora', system-ui, sans-serif;
  font-size: 14.5px;
  min-height: 100vh;
  overflow-x: hidden; width: 100%; max-width: 100vw;
  padding-top: 56px;
  -webkit-font-smoothing: antialiased;
  transition: background-color 0.2s, color 0.2s;
}
a { color: var(--link); text-decoration: none; transition: color 0.15s; }
a:hover { color: var(--text); }
a:visited { color: var(--link-visited); }

/* ---------- Nav ---------- */
nav {
  position: fixed; top: 0; left: 0; right: 0; z-index: 100;
  background: var(--header-bg);
  border-bottom: 1px solid var(--line);
  padding: 0 1.75rem; height: 56px; display: flex; align-items: center; gap: 1.5rem;
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
}
.nav-brand {
  font-weight: 700; font-size: 1.02rem; color: var(--text); letter-spacing: -0.01em;
  text-decoration: none;
}
.nav-brand::before { content: 'S16'; color: var(--accent); margin-right: 0.4rem; }
.nav-links { display: flex; gap: 1.5rem; list-style: none; margin-left: auto; align-items: center; }
.nav-links a {
  font-size: 0.8rem; color: var(--muted); font-weight: 500;
  padding-bottom: 2px; border-bottom: 1.5px solid transparent;
}
.nav-links a.active { color: var(--text); border-bottom-color: var(--accent); }
.nav-links a:hover { color: var(--text); }

.theme-toggle {
  display: flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; padding: 0; flex-shrink: 0;
  color: var(--muted); background: var(--row); border: 1px solid var(--line);
  border-radius: 100px; 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; }

/* ---------- Layout ---------- */
.hero { max-width: 980px; margin: 0 auto; padding: 1.9rem 1.75rem 0.9rem; }
.hero h1 { font-size: 1.3rem; font-weight: 700; color: var(--text); letter-spacing: -0.01em; }
.container { max-width: 980px; margin: 0 auto; padding: 0.75rem 1.75rem 4rem; }
.section-label {
  font-family: 'IBM Plex Mono', monospace; font-size: 0.68rem; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--muted); margin-bottom: 0.85rem; font-weight: 500;
}

/* ---------- Cards ---------- */
.card {
  background: var(--row);
  border: 1px solid var(--line); border-radius: 10px; padding: 1.35rem 1.5rem; margin-bottom: 1rem;
  transition: border-color 0.15s;
}
.card:hover { border-color: var(--line); }
.card-link { text-decoration: none; display: block; }

.thread-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; margin-bottom: 0.45rem; }
.thread-title { font-weight: 700; font-size: 0.98rem; letter-spacing: -0.005em; color: var(--text); }
.thread-meta { font-family: 'IBM Plex Mono', monospace; font-size: 0.72rem; color: var(--muted); letter-spacing: 0.01em; }

.reply-badge {
  font-family: 'IBM Plex Mono', monospace; font-size: 0.66rem; letter-spacing: 0.02em;
  color: var(--muted); background: rgba(255,255,255,0.04); border: 1px solid var(--line);
  border-radius: 100px; padding: 0.22rem 0.65rem; white-space: nowrap; flex-shrink: 0;
}
[data-theme="light"] .reply-badge { background: rgba(0,0,0,0.03); }
.lock-badge {
  font-family: 'IBM Plex Mono', monospace; font-size: 0.62rem; letter-spacing: 0.02em;
  color: var(--muted); background: var(--card2); border: 1px solid var(--line);
  border-radius: 100px; padding: 0.22rem 0.65rem; margin-left: 0.5rem;
}
.new-badge {
  font-family: 'IBM Plex Mono', monospace; font-size: 0.6rem; letter-spacing: 0.04em;
  color: var(--accent); background: var(--accent-soft); border: 1px solid rgba(232,176,78,0.3);
  border-radius: 100px; padding: 0.22rem 0.65rem; margin-left: 0.5rem; text-transform: uppercase;
}
.active-dot {
  display: inline-block; width: 7px; height: 7px; border-radius: 50%;
  background: var(--green); box-shadow: 0 0 6px var(--green); margin: 0 0.4rem; vertical-align: middle;
}

/* ---------- Reactions ---------- */
.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: var(--card2); border: 1px solid var(--line); border-radius: 100px;
  padding: 0.3rem 0.6rem; font-size: 0.9rem; cursor: pointer; transition: border-color 0.15s, transform 0.1s;
}
.reaction-btn:hover { border-color: var(--accent); transform: translateY(-1px); }
.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(--line); transform: none; }
.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; letter-spacing: 0.02em;
  background: none; border: 1px solid var(--line); 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(--row); border: 1px solid var(--line); border-radius: 100px;
  padding: 0.35rem; gap: 0.15rem; box-shadow: 0 8px 24px rgba(0,0,0,0.3);
}
.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, transform 0.1s;
}
.reaction-picker-btn:hover { background: var(--card2); transform: scale(1.15); }
.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 rgba(232,176,78,0.5); pointer-events: none;
}

.empty-card { border: 1px dashed var(--line); border-radius: 10px; padding: 2rem; text-align: center; color: var(--muted); font-family: 'IBM Plex Mono', monospace; font-size: 0.72rem; letter-spacing: 0.04em; }
.error-card { border: 1px solid rgba(239,139,139,0.35); background: rgba(239,139,139,0.06); color: var(--red); border-radius: 10px; padding: 1rem 1.25rem; font-size: 0.85rem; margin-bottom: 1rem; }
.success-card { border: 1px solid rgba(123,201,154,0.35); background: rgba(123,201,154,0.06); color: var(--green); border-radius: 10px; padding: 1rem 1.25rem; font-size: 0.85rem; margin-bottom: 1rem; }

/* ---------- Buttons & forms ---------- */
button, input, textarea { font-family: inherit; }
.btn {
  font-family: 'Sora', sans-serif; font-size: 0.8rem; font-weight: 600;
  color: var(--text); background: var(--row); border: 1px solid var(--line);
  border-radius: 6px; padding: 0.6rem 1.1rem; 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(239,139,139,0.4); color: var(--red); }
.btn-danger:hover { background: rgba(239,139,139,0.08); }
.btn-new { font-family: 'Sora', sans-serif; font-size: 0.8rem; font-weight: 600; color: #191a1f; background: var(--accent); padding: 0.55rem 1rem; border: none; border-radius: 6px; cursor: pointer; transition: filter 0.15s; }
.btn-new:hover { filter: brightness(1.08); }

.field { margin-bottom: 1.1rem; }
.field label { display: block; font-family: 'IBM Plex Mono', monospace; font-size: 0.66rem; letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted); margin-bottom: 0.4rem; }
.field input, .field textarea {
  width: 100%; background: var(--card2); border: 1px solid var(--line); border-radius: 6px;
  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-family: 'IBM Plex Mono', monospace; font-size: 0.64rem; color: var(--muted); margin-top: 0.4rem; letter-spacing: 0.01em; }

/* ---------- Posts (thread page) ---------- */
.post { border-bottom: 1px solid var(--line-soft); padding: 1.25rem 0; }
.post:last-child { border-bottom: none; }
.post-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 0.5rem; flex-wrap: wrap; gap: 0.4rem; }
.post-author { font-weight: 700; font-size: 0.85rem; color: var(--accent); }
.post-date { font-family: 'IBM Plex Mono', monospace; font-size: 0.66rem; color: var(--muted); }
.post-content { font-size: 0.92rem; line-height: 1.65; white-space: pre-wrap; }
.post-content.deleted { color: var(--muted); font-style: italic; }
.post-actions { margin-top: 0.5rem; }
.report-link { font-family: 'IBM Plex Mono', monospace; font-size: 0.64rem; color: var(--muted); background: none; border: none; cursor: pointer; letter-spacing: 0.02em; text-decoration: underline; padding: 0; }
.report-link:hover { color: var(--red); }

/* ---------- Captcha ---------- */
.captcha-box {
  display: flex; align-items: center; gap: 0.85rem;
  background: var(--card2); border: 1px solid var(--line); border-radius: 6px;
  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-family: 'IBM Plex Mono', monospace; font-size: 0.62rem; letter-spacing: 0.02em;
  color: var(--red); background: rgba(239,139,139,0.1); border: 1px solid rgba(239,139,139,0.3);
  border-radius: 100px; padding: 0.22rem 0.65rem; margin-left: 0.5rem;
}

/* ---------- Footer ---------- */
footer { border-top: 1px solid var(--line); padding: 1.5rem 1.75rem; display: flex; align-items: center; justify-content: center; gap: 0.75rem; max-width: 980px; margin: 0 auto; }
.footer-text { font-family: 'IBM Plex Mono', monospace; font-size: 0.66rem; color: var(--muted); letter-spacing: 0.03em; }

/* ---------- Level / XP badges ---------- */
.level-badge {
  display: inline-flex; align-items: center; gap: 0.3rem;
  font-family: 'IBM Plex Mono', monospace; font-size: 0.64rem; letter-spacing: 0.02em;
  padding: 0.16rem 0.55rem; border-radius: 100px; border: 1px solid currentColor;
  white-space: nowrap;
}
.level-badge .lvl-num { font-weight: 700; }
.badge { display: inline-flex; align-items: center; font-size: 0.66rem; font-weight: 600; letter-spacing: 0.02em; padding: 0.15rem 0.5rem; border-radius: 5px; text-transform: uppercase; background: rgba(255,255,255,0.05); color: var(--muted); }
.badge.veteran { background: var(--accent-soft); color: var(--accent); }

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

.xp-panel { background: var(--row); border: 1px solid var(--line); border-radius: 10px; padding: 1.1rem 1.25rem; 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.95rem; }
.xp-panel-sub { font-family: 'IBM Plex Mono', monospace; font-size: 0.62rem; color: var(--muted); }
.xp-bar-track { width: 100%; height: 6px; border-radius: 100px; background: var(--card2); overflow: hidden; }
.xp-bar-fill { height: 100%; border-radius: 100px; background: var(--accent); transition: width 0.4s ease; }

.author-link { font-weight: 700; font-size: 0.85rem; color: var(--accent); text-decoration: none; border-radius: 6px; padding: 0.05rem 0.3rem; transition: opacity 0.15s; }
.author-link:hover { opacity: 0.8; text-decoration: underline; }
.author-link-static { cursor: default; }
.author-link-static:hover { opacity: 1; text-decoration: none; }

.perk-frame { border: 1px solid rgba(232,176,78,0.4); }
.perk-gradient {
  background: linear-gradient(90deg, var(--accent), var(--violet), var(--accent));
  background-size: 200% auto;
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
  animation: gradientShift 4s ease infinite;
}
@keyframes gradientShift { 0% { background-position: 0% center; } 100% { background-position: 200% center; } }
.perk-sparkle { display: inline-block; margin-right: 0.2rem; animation: sparklePulse 1.8s ease-in-out infinite; }
@keyframes sparklePulse { 0%, 100% { opacity: 0.4; transform: scale(0.9); } 50% { opacity: 1; transform: scale(1.1); } }

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

/* ---------- Members / homepage ---------- */
.members-grid { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.member-chip {
  display: inline-flex; align-items: center; gap: 0.3rem;
  background: var(--row); border: 1px solid var(--line); border-radius: 100px;
  padding: 0.4rem 0.8rem; text-decoration: none; transition: border-color 0.15s;
}
.member-chip:hover { border-color: var(--accent); }
.member-chip-name { font-weight: 600; font-size: 0.78rem; color: var(--text); }

/* ---------- Profile ---------- */
.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: 800; font-size: 1.4rem; color: var(--text); }
.profile-stat-label { font-family: 'IBM Plex Mono', monospace; font-size: 0.62rem; letter-spacing: 0.03em; color: var(--muted); text-transform: uppercase; }

.badge-chip {
  display: inline-flex; align-items: center; gap: 0.35rem;
  background: var(--card2); border: 1px solid var(--line); border-radius: 100px;
  padding: 0.4rem 0.8rem; font-size: 0.8rem;
}

.badge-pill {
  display: inline-flex; align-items: center; gap: 0.3rem;
  font-size: 0.7rem; padding: 0.2rem 0.55rem; border-radius: 100px;
  background: var(--card2); border: 1px solid var(--line); color: var(--muted);
}

/* ---------- Board table (accueil-style, disponible si besoin) ---------- */
.board { background: var(--row); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
table { width: 100%; border-collapse: collapse; }
thead tr { background: var(--header-bg); }
th { text-align: left; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); font-weight: 600; padding: 0.75rem 1.1rem; border-bottom: 1px solid var(--line); }
th.num { text-align: center; width: 100px; }
th.last { width: 200px; }
tbody tr { border-bottom: 1px solid var(--line-soft); transition: background 0.12s; }
tbody tr:last-child { border-bottom: none; }
tbody tr:nth-child(even) { background: var(--row-alt); }
tbody tr:hover { background: var(--row-hover); }
td { padding: 0.85rem 1.1rem; vertical-align: middle; }
td.num { text-align: center; color: var(--muted); font-family: 'IBM Plex Mono', monospace; font-size: 0.85rem; }
td.last { font-size: 0.8rem; color: var(--muted); line-height: 1.5; }
td.last .date { color: var(--accent); font-weight: 500; }
.pin { color: var(--accent); margin-right: 0.45rem; font-size: 0.78rem; opacity: 0.85; }

/* ---------- Reward toast ---------- */
.reward-toast {
  position: fixed; left: 50%; bottom: 84px; transform: translateX(-50%) translateY(20px);
  background: var(--accent);
  color: #191a1f; font-family: 'IBM Plex Mono', monospace; font-size: 0.72rem; letter-spacing: 0.01em;
  padding: 0.65rem 1.1rem; border-radius: 100px; box-shadow: 0 8px 24px rgba(0,0,0,0.35);
  z-index: 300; opacity: 0; transition: opacity 0.25s, transform 0.25s; pointer-events: none;
  white-space: nowrap; font-weight: 600;
}
.reward-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
@media (min-width: 721px) { .reward-toast { bottom: 28px; } }

/* ---------- Responsive ---------- */
@media (max-width: 720px) {
  nav { padding: 0 1rem; gap: 0.6rem; height: 54px; }
  .nav-brand { font-size: 0.88rem; 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: 54px; padding-bottom: 64px; }

  .hero { padding: 1.5rem 1.25rem 0.75rem; }
  .hero h1 { font-size: 1.1rem; }
  .container { padding: 0.75rem 1.25rem 4rem; }

  .card { padding: 1.1rem 1.15rem; }
  .thread-header { flex-direction: column; gap: 0.5rem; align-items: flex-start; }
  .reply-badge { align-self: flex-start; }
  .thread-title { font-size: 0.94rem; }

  .btn { padding: 0.6rem 0.9rem; font-size: 0.75rem; }
  .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.5rem 1.25rem; flex-wrap: wrap; text-align: center; }

  .profile-stats-grid { grid-template-columns: repeat(3, 1fr); gap: 0.5rem; }
  .profile-stat-value { font-size: 1.15rem; }
}

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

/* ---------- Bottom nav (mobile) ---------- */
.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(--header-bg);
    border-top: 1px solid var(--line);
    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-family: 'IBM Plex Mono', monospace; font-size: 0.58rem; letter-spacing: 0.01em;
    text-transform: uppercase; 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; }
}
