:root {
  --bg: #080b0d;
  --panel: #0d1216;
  --border: #26313a;
  --border-soft: #1b252d;
  --text: #e7edf1;
  --muted: #8996a1;
  --muted-2: #61707c;
  --accent: #d7ff45;
  --orange: #ff6b1a;
  --blue: #5da9ff;
  --purple: #a77bff;
  --danger: #ff6b6b;
  --up: #ff6b35;
  --down: #6baeff;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
}
button, input, textarea, select { font: inherit; }
button { border: 0; color: inherit; cursor: pointer; background: none; }
a { color: inherit; text-decoration: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
[hidden] { display: none !important; }

.app {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 230px minmax(0, 1fr) 310px;
  grid-template-rows: 58px 1fr;
}

/* Top bar */
.topbar {
  grid-column: 1 / -1;
  display: flex; align-items: center; gap: 22px;
  padding: 0 18px;
  background: rgba(8, 11, 13, .96);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 20;
}
.brand { width: 190px; display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 18px; letter-spacing: -.3px; }
.brand-mark {
  width: 31px; height: 31px; border: 2px solid var(--accent); border-radius: 9px;
  display: grid; place-items: center; color: var(--accent);
  box-shadow: 0 0 18px rgba(215,255,69,.08);
}
.brand-mark::before { content: "◆"; font-size: 12px; }
.search {
  height: 38px; max-width: 650px; flex: 1;
  display: flex; align-items: center; gap: 10px; padding: 0 14px;
  background: #111820; border: 1px solid #202c35; border-radius: 20px; color: var(--muted);
}
.search input { width: 100%; outline: 0; border: 0; background: transparent; color: var(--text); }
.search input::placeholder { color: #687681; }
.top-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.pill {
  height: 36px; display: inline-flex; align-items: center; gap: 7px;
  border: 1px solid var(--border); background: #0f151a; border-radius: 18px;
  padding: 0 14px; color: #b9c5cc; font-weight: 700;
}
.pill:hover { border-color: #3a4852; color: var(--text); }
.pill.accent { color: #0a0d0e; background: var(--accent); border-color: var(--accent); font-weight: 800; }
.pill.accent:hover { background: #e4ff78; }
.user-chip { display: inline-flex; align-items: center; gap: 8px; color: #c6d0d6; font-weight: 700; font-size: 13px; padding: 0 6px; }
.avatar {
  width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center;
  background: #18242b; color: var(--accent); font-weight: 800; font-size: 12px; text-transform: uppercase;
}
.badge { font-size: 10px; font-weight: 800; color: #0a0d0e; background: var(--accent); padding: 2px 7px; border-radius: 9px; }

/* Sidebar */
.sidebar {
  border-right: 1px solid var(--border); background: #090d10; padding: 18px 12px;
  position: sticky; top: 58px; height: calc(100vh - 58px); overflow: auto;
}
.nav-section { margin: 0 7px 9px; color: #63717c; font-size: 11px; font-weight: 800; letter-spacing: .04em; }
.nav-item {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px; margin: 2px 0;
  border-radius: 7px; color: #aeb9c1; transition: background .15s ease, color .15s ease; width: 100%; text-align: left;
}
.nav-item:hover, .nav-item.active { background: #172129; color: var(--text); }
.nav-item.active { box-shadow: inset 3px 0 var(--accent); }
.nav-icon { width: 19px; text-align: center; color: #8b99a4; }
.nav-item.active .nav-icon { color: var(--accent); }
.community { margin-top: 25px; }
.sidebar-bottom { margin-top: 55px; padding: 0 9px; color: #52606a; font-size: 11px; line-height: 1.8; }

/* Main */
.main { min-width: 0; padding: 28px 26px 70px; }
.wrap { max-width: 860px; margin: 0 auto; }
.community-header { display: flex; align-items: center; gap: 15px; padding-bottom: 22px; border-bottom: 1px solid var(--border); }
.community-logo {
  width: 55px; height: 55px; flex: 0 0 auto; display: grid; place-items: center;
  border-radius: 14px; border: 1px solid #384700; color: var(--accent); background: #111703; font-size: 25px; font-weight: 800;
}
.community-title { flex: 1; min-width: 0; }
.community-title h1 { margin: 0 0 3px; font-size: 24px; letter-spacing: -.5px; }
.community-title p { margin: 0; color: var(--muted); }
.new-topic { background: var(--orange); color: white; border-radius: 18px; padding: 10px 15px; font-weight: 800; white-space: nowrap; }
.new-topic:hover { background: #ff7c33; }
.join-inline { margin-right: 4px; }
.join-inline.joined { color: var(--muted); }

.sortbar { margin-top: 14px; display: flex; gap: 6px; border-bottom: 1px solid var(--border); padding-bottom: 9px; }
.sort { color: var(--muted); border-radius: 7px; padding: 8px 12px; font-weight: 700; }
.sort:hover { background: #182127; color: var(--text); }
.sort.selected { background: #182127; color: var(--accent); }

.post {
  display: grid; grid-template-columns: 52px minmax(0, 1fr); gap: 14px;
  padding: 19px 4px; border-bottom: 1px solid var(--border-soft); transition: background .15s;
}
.post:hover { background: rgba(255,255,255,.018); }
.post-content { min-width: 0; }
.meta { display: flex; align-items: center; flex-wrap: wrap; gap: 7px; color: var(--muted-2); font-size: 11px; margin-bottom: 7px; }
.meta a:hover { color: var(--text); text-decoration: underline; }
.meta .sub { color: #c6d0d6; font-weight: 800; }
.tag {
  display: inline-flex; align-items: center; border-radius: 12px; padding: 4px 9px;
  color: #061006; font-size: 10px; font-weight: 900;
}
.tag.feature { background: var(--accent); }
.tag.help { background: var(--blue); }
.tag.discussion { background: var(--purple); color: white; }
.tag.question { background: var(--orange); color: white; }
.tag.performance { background: #2e9ee9; color: white; }
.post h2 { margin: 0 0 7px; font-size: 17px; letter-spacing: -.15px; }
.post h2 a:hover { color: var(--accent); }
.post p { margin: 0; max-width: 760px; color: #9aa7b0; line-height: 1.5; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }

.vote-box {
  width: 44px; min-height: 92px; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 1px; padding: 4px 0; border: 1px solid #202b33; background: #0e151a; border-radius: 10px;
}
.vote-box.row { width: auto; min-height: 0; flex-direction: row; padding: 0 3px; border-radius: 17px; }
.vote-btn {
  width: 34px; height: 29px; display: grid; place-items: center; padding: 0;
  border-radius: 7px; color: #788792; transition: color .15s ease, background .15s ease;
}
.vote-btn svg { width: 17px; height: 17px; fill: currentColor; }
.vote-btn.up:hover, .vote-btn.up.voted { color: var(--up); background: rgba(255,107,53,.10); }
.vote-btn.down:hover, .vote-btn.down.voted { color: var(--down); background: rgba(107,174,255,.10); }
.score { min-width: 30px; text-align: center; color: #d7e0e5; font-size: 12px; line-height: 18px; font-weight: 850; }
.score.up { color: var(--up); }
.score.down { color: var(--down); }

.post-footer { display: flex; align-items: center; flex-wrap: wrap; gap: 4px; margin-top: 12px; }
.post-action {
  height: 30px; display: inline-flex; align-items: center; gap: 7px; padding: 0 9px;
  border-radius: 7px; color: #74828c; font-size: 11px; font-weight: 700;
}
.post-action svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.post-action:hover { background: #172128; color: #d5dee3; }
.post-action.danger:hover { color: var(--danger); background: rgba(255,107,107,.08); }

.empty { padding: 50px 10px; text-align: center; color: var(--muted); line-height: 1.6; }
.empty strong { display: block; color: var(--text); font-size: 16px; margin-bottom: 6px; }
.empty .new-topic { display: inline-block; margin-top: 14px; }

/* Thread */
.back-link { display: inline-flex; gap: 6px; color: var(--muted); font-size: 12px; font-weight: 700; margin-bottom: 14px; }
.back-link:hover { color: var(--text); }
.thread { border: 1px solid var(--border); border-radius: 10px; overflow: hidden; background: #0b1115; }
.thread-header { padding: 22px 22px 0; }
.thread-header h2 { margin: 10px 0 0; font-size: 22px; letter-spacing: -.3px; line-height: 1.3; }
.thread-body { padding: 16px 22px 20px; color: #b1bcc4; line-height: 1.65; }
.thread-text { white-space: pre-wrap; overflow-wrap: anywhere; }
.thread-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 5px; margin-top: 18px; padding-top: 13px; border-top: 1px solid #182229; }

.comments { border-top: 1px solid var(--border); padding: 20px 22px 28px; }
.comments-head { display: flex; justify-content: space-between; color: #c6d0d6; font-weight: 800; margin-bottom: 18px; }
.comment { position: relative; margin-left: 4px; padding: 0 0 17px 25px; border-left: 2px solid #202c34; }
.comment .comment { margin-left: 22px; margin-top: 14px; padding-bottom: 0; }
.comment::before {
  content: ""; position: absolute; left: -6px; top: 4px; width: 10px; height: 10px;
  border-radius: 50%; background: #26333c; border: 2px solid #0b1115;
}
.comment-meta { color: #71808b; font-size: 11px; margin-bottom: 5px; }
.comment-meta strong { color: #b9c5cc; }
.comment-meta .op { color: var(--accent); font-weight: 800; margin-left: 4px; }
.comment-body { margin: 0; color: #9ba8b1; line-height: 1.55; font-size: 13px; white-space: pre-wrap; overflow-wrap: anywhere; }
.comment-body.deleted { color: var(--muted-2); font-style: italic; }
.comment-actions { margin-top: 7px; display: flex; align-items: center; gap: 3px; color: #66757f; font-size: 11px; }
.comment-action {
  display: inline-flex; align-items: center; gap: 5px; height: 27px; padding: 0 7px;
  border-radius: 6px; color: inherit; font-weight: 700;
}
.comment-action:hover { background: #172128; color: #cbd5db; }
.comment-action.voted-up, .comment-action.voted-up:hover { color: var(--up); }
.comment-action.voted-down, .comment-action.voted-down:hover { color: var(--down); }
.comment-action.danger:hover { color: var(--danger); }
.comment-action.reply-btn:hover { color: var(--accent); }

.composer-box { margin-bottom: 22px; }
.composer-box textarea, .field input, .field textarea, .field select {
  width: 100%; background: #0e151a; color: var(--text); border: 1px solid #25313a;
  border-radius: 9px; padding: 11px 12px; outline: 0; resize: vertical; line-height: 1.5;
}
.composer-box textarea { min-height: 88px; }
.composer-box textarea:focus, .field input:focus, .field textarea:focus, .field select:focus { border-color: #4a5a1a; }
.composer-row { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }
.btn { height: 34px; padding: 0 15px; border-radius: 17px; font-weight: 800; font-size: 12px; }
.btn.primary { background: var(--accent); color: #0a0d0e; }
.btn.primary:disabled { opacity: .5; cursor: default; }
.btn.ghost { color: var(--muted); }
.btn.ghost:hover { color: var(--text); background: #172128; }

.gate {
  display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap;
  border: 1px solid #2c3a13; background: #0f1508; border-radius: 10px; padding: 14px 16px; margin: 4px 0 20px;
}
.gate p { margin: 0; color: #c6d0d6; line-height: 1.5; }
.gate p span { display: block; color: var(--muted); font-size: 12px; }
.gate-actions { display: flex; gap: 8px; }
.gate.locked { margin: 6px 0 0; border-style: dashed; }

/* Right rail */
.rightbar {
  border-left: 1px solid var(--border); background: #090d10; padding: 18px 14px;
  position: sticky; top: 58px; height: calc(100vh - 58px); overflow: auto;
}
.card { border: 1px solid var(--border); background: #0c1216; border-radius: 10px; padding: 16px; margin-bottom: 13px; }
.card-title { font-weight: 800; margin-bottom: 7px; }
.card-header { display: flex; align-items: center; gap: 10px; margin-bottom: 13px; }
.mini-logo { width: 39px; height: 39px; border: 1px solid #394700; border-radius: 50%; display: grid; place-items: center; color: var(--accent); font-weight: 800; }
.card h3 { margin: 0 0 3px; font-size: 14px; }
.card p { color: #8b99a4; line-height: 1.5; font-size: 12px; }
.card-sub { font-size: 11px; color: #71808b; }
.join { width: 100%; border-radius: 17px; padding: 9px; background: var(--orange); color: white; font-weight: 900; margin: 8px 0 4px; }
.join.joined { background: transparent; border: 1px solid var(--border); color: #b9c5cc; }
.rules { margin: 10px -2px 0; padding: 0; list-style: none; counter-reset: rule; }
.rules li { counter-increment: rule; display: flex; gap: 9px; padding: 8px 0; border-top: 1px solid #192229; color: #a1adb5; font-size: 11px; }
.rules li::before { content: counter(rule); color: #61707b; min-width: 12px; }
.quick-link { display: flex; gap: 9px; padding: 8px 0; color: #a3afb7; font-size: 12px; }
.quick-link:hover { color: var(--accent); }
.related { display: flex; align-items: center; gap: 9px; padding: 8px 0; border-bottom: 1px solid #192229; }
.related:last-child { border-bottom: 0; }
.related-dot { width: 26px; height: 26px; flex: 0 0 auto; border-radius: 50%; background: #18242b; display: grid; place-items: center; color: var(--accent); font-size: 11px; }
.related-title { min-width: 0; font-size: 12px; line-height: 1.35; }
.related-title:hover { color: var(--accent); }
.related-title small { display: block; color: #5f6d77; margin-top: 2px; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }

/* Modal */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 50; background: rgba(3,5,6,.72);
  display: grid; place-items: center; padding: 16px;
}
.modal {
  width: min(560px, 100%); max-height: calc(100vh - 32px); overflow: auto;
  background: #0c1216; border: 1px solid var(--border); border-radius: 14px; padding: 22px;
  box-shadow: 0 30px 80px rgba(0,0,0,.5);
}
.modal h2 { margin: 0 0 6px; font-size: 19px; letter-spacing: -.3px; }
.modal .lead { margin: 0 0 18px; color: var(--muted); line-height: 1.5; }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12px; font-weight: 700; color: #b9c5cc; margin-bottom: 6px; }
.field .hint { font-size: 11px; color: var(--muted-2); margin-top: 5px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-error { color: var(--danger); font-size: 12px; min-height: 16px; margin: 4px 0 8px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 60;
  background: #172128; border: 1px solid #2c3a44; color: var(--text); padding: 10px 16px; border-radius: 10px; font-size: 13px;
}

/* ---------- Pages multiples : profil, paramètres, vérification ---------- */
.app.no-rail { grid-template-columns: 230px minmax(0, 1fr); }
.app.no-rail .rightbar { display: none; }
.search-form { flex: 1; max-width: 650px; display: flex; }
.search-form .search { width: 100%; max-width: none; }

img.avatar, .avatar { object-fit: cover; flex: 0 0 auto; }
.avatar.sm { width: 20px; height: 20px; font-size: 10px; }
.avatar.md { width: 28px; height: 28px; }
.avatar.lg { width: 96px; height: 96px; font-size: 38px; border: 3px solid #0b1115; box-shadow: 0 0 0 1px var(--border); }
.avatar.xl { width: 120px; height: 120px; font-size: 46px; }
.author { display: inline-flex; align-items: center; gap: 6px; }
.author:hover .author-name { color: var(--text); text-decoration: underline; }
.comment-meta .author { vertical-align: middle; }

.page-title { margin: 0 0 4px; font-size: 24px; letter-spacing: -.5px; }
.page-lead { margin: 0 0 22px; color: var(--muted); }

.profile-hero {
  display: flex; gap: 20px; align-items: center; padding: 6px 0 24px;
  border-bottom: 1px solid var(--border);
}
.profile-hero h1 { margin: 0; font-size: 26px; letter-spacing: -.5px; overflow-wrap: anywhere; }
.profile-hero .handle { color: var(--muted); margin-top: 3px; }
.profile-hero .bio { margin: 10px 0 0; color: #b1bcc4; line-height: 1.55; white-space: pre-wrap; max-width: 60ch; }
.profile-hero .grow { flex: 1; min-width: 0; }
.stats { display: flex; gap: 22px; margin-top: 14px; color: var(--muted); font-size: 12px; flex-wrap: wrap; }
.stats b { display: block; color: var(--text); font-size: 16px; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin: 14px 0 0; }
.tab { padding: 10px 14px; color: var(--muted); font-weight: 800; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tab:hover { color: var(--text); }
.tab[aria-selected="true"] { color: var(--text); border-bottom-color: var(--accent); }

.activity { padding: 16px 4px; border-bottom: 1px solid var(--border-soft); }
.activity .meta { margin-bottom: 6px; }
.activity .ctx { font-weight: 700; color: #c6d0d6; }
.activity .ctx:hover { color: var(--accent); }
.activity p { margin: 0; color: #9ba8b1; line-height: 1.55; white-space: pre-wrap; overflow-wrap: anywhere; }

.settings { display: grid; gap: 16px; max-width: 720px; }
.panel { border: 1px solid var(--border); background: #0b1115; border-radius: 12px; padding: 20px 22px; }
.panel h2 { margin: 0 0 4px; font-size: 16px; }
.panel > .sub { margin: 0 0 18px; color: var(--muted); font-size: 13px; line-height: 1.5; }
.avatar-row { display: flex; align-items: center; gap: 18px; margin-bottom: 18px; flex-wrap: wrap; }
.avatar-row .hint { font-size: 11px; color: var(--muted-2); margin-top: 6px; }
.row-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.kv { display: grid; grid-template-columns: 150px 1fr; gap: 10px 16px; font-size: 13px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; color: var(--text); overflow-wrap: anywhere; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { font-size: 11px; font-weight: 700; padding: 3px 9px; border-radius: 10px; background: #172128; color: #b9c5cc; }
.email-current { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; font-size: 14px; }
.status { font-size: 11px; font-weight: 800; padding: 3px 9px; border-radius: 10px; }
.status.ok { background: rgba(75,210,123,.14); color: #6fe39a; }
.status.wait { background: rgba(255,107,26,.14); color: #ff9a5c; }
.notice { border-radius: 10px; padding: 12px 14px; margin-bottom: 16px; font-size: 13px; line-height: 1.5; }
.notice.ok { background: rgba(75,210,123,.08); border: 1px solid rgba(75,210,123,.3); color: #b9f0cd; }
.notice.wait { background: rgba(255,107,26,.07); border: 1px solid rgba(255,107,26,.3); color: #ffd2b5; }
.notice.err { background: rgba(255,107,107,.07); border: 1px solid rgba(255,107,107,.3); color: #ffc9c9; }
.notice .row-actions { margin-top: 10px; }
.inline-form { display: flex; gap: 8px; flex-wrap: wrap; }
.inline-form input { flex: 1; min-width: 220px; }
.btn.danger { color: var(--danger); }
.btn.danger:hover { background: rgba(255,107,107,.08); }
.btn.outline { border: 1px solid var(--border); color: #c6d0d6; }
.btn.outline:hover { border-color: #3a4852; color: var(--text); }
.center-card { max-width: 480px; margin: 40px auto; text-align: center; }
.center-card .panel { padding: 30px 26px; }
.center-card h1 { margin: 0 0 8px; font-size: 22px; }
.center-card p { color: var(--muted); line-height: 1.55; margin: 0 0 20px; }
.big-code { font-size: 64px; font-weight: 900; letter-spacing: -2px; color: var(--accent); margin: 0; }

@media (max-width: 1100px) {
  .app { grid-template-columns: 205px minmax(0, 1fr); }
  .rightbar { display: none; }
  .brand { width: 165px; }
}
@media (max-width: 720px) {
  .app { display: block; }
  .sidebar, .search { display: none; }
  .main { padding: 18px 10px 50px; }
  .community-title h1 { font-size: 19px; }
  .community-title p { font-size: 11px; }
  .new-topic { padding: 8px 11px; }
  .post { grid-template-columns: 40px minmax(0,1fr); gap: 8px; }
  .vote-box { width: 40px; min-height: 88px; }
  .brand { width: auto; }
  .user-chip .name, .pill .label { display: none; }
  .field-row { grid-template-columns: 1fr; }
  .comments, .thread-body { padding-left: 14px; padding-right: 14px; }
  .profile-hero { flex-direction: column; align-items: flex-start; }
  .topbar { gap: 10px; padding: 0 10px; }
  .top-actions { gap: 5px; }
  .pill { padding: 0 11px; }
  .user-chip { padding: 0 2px; }
  .kv { grid-template-columns: 1fr; gap: 2px; }
  .kv dd { margin-bottom: 10px; }
  .panel { padding: 18px 16px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; scroll-behavior: auto !important; } }

/* ---------- Pages de connexion / inscription ---------- */
.auth-page { min-height: 100vh; }
.auth-shell {
  min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 22px; padding: 40px 16px;
}
.auth-shell .brand { width: auto; }
.auth-card {
  width: min(420px, 100%); background: #0b1115; border: 1px solid var(--border);
  border-radius: 14px; padding: 28px 26px 22px;
}
.auth-card h1 { margin: 0 0 6px; font-size: 22px; letter-spacing: -.4px; }
.auth-lead { margin: 0 0 22px; color: var(--muted); line-height: 1.5; }
.auth-form .field input { height: 42px; }
.password-wrap { position: relative; }
.password-wrap input { padding-right: 64px; }
.reveal {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  height: 30px; padding: 0 10px; border-radius: 7px; color: var(--muted); font-size: 12px; font-weight: 700;
}
.reveal:hover { color: var(--text); background: #172128; }
.auth-submit { width: 100%; height: 42px; font-size: 14px; margin-top: 6px; }
.auth-submit:disabled { opacity: .6; cursor: progress; }
.auth-switch { margin: 18px 0 0; text-align: center; color: var(--muted); font-size: 13px; }
.auth-switch a, .auth-back:hover { color: var(--accent); }
.auth-switch a:hover { text-decoration: underline; }
.auth-back { color: var(--muted); font-size: 12px; font-weight: 700; }
.field input.touched:invalid:not(:focus) { border-color: rgba(255,107,107,.5); }
