:root {
  --violet-deep: #2B0F52;
  --violet-mid: #45208C;
  --violet-bright: #8A5CF0;
  --yellow: #F9DD3B;
  --yellow-dim: #C99A2C;
  --paper: #F1E7D0;
  --paper-dark: #DFC998;
  --cream: #F6EFE2;
  --ink: #241436;

  --display: "Fraunces", serif;
  --mono: "Space Mono", monospace;
  --body: "Work Sans", sans-serif;

  --sidebar-width: 320px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--body);
  background: var(--violet-deep);
  color: var(--cream);
}

h1, h2, h3 { font-family: var(--display); margin: 0; }

img { max-width: 100%; }

.hidden { display: none !important; }

button, input, textarea { font: inherit; }

/* --- écran plein page (auth / vérification) --- */

.screen-center {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.auth-card {
  width: min(400px, 100%);
  background: var(--paper);
  color: var(--ink);
  border-radius: 12px;
  padding: 36px 32px;
  box-shadow: 0 18px 40px rgba(0,0,0,.35);
  text-align: center;
}

.auth-card h1 {
  color: var(--violet-deep);
  font-size: 1.8rem;
  margin-bottom: 4px;
}

.auth-card .tagline {
  font-family: var(--mono);
  font-size: .72rem;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--yellow-dim);
  margin-bottom: 24px;
}

.auth-form, .inline-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

input, textarea {
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--paper-dark);
  background: var(--cream);
  color: var(--ink);
}

textarea { min-height: 4rem; resize: vertical; }

.btn-primary {
  padding: 10px 16px;
  border-radius: 999px;
  border: none;
  background: var(--violet-mid);
  color: var(--cream);
  cursor: pointer;
  font-weight: 600;
  transition: background .2s ease, transform .15s ease;
}
.btn-primary:hover { background: var(--violet-bright); transform: translateY(-1px); }

.btn-secondary {
  padding: 10px 16px;
  border-radius: 999px;
  border: 1px solid var(--violet-mid);
  background: transparent;
  color: var(--violet-mid);
  cursor: pointer;
}
.btn-secondary:hover { border-color: var(--violet-bright); color: var(--violet-bright); }

.btn-discord {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 16px;
  border-radius: 999px;
  border: none;
  background: #5865F2;
  color: white;
  text-decoration: none;
  font-weight: 600;
}
.btn-discord img { width: 18px; height: 18px; filter: brightness(0) invert(1); }
.btn-discord:hover { background: #4752c4; }

.divider {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--yellow-dim);
  font-family: var(--mono);
  font-size: .7rem;
  text-transform: uppercase;
  margin: 4px 0;
}
.divider::before, .divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--paper-dark);
}

.link-button {
  background: none;
  border: none;
  color: var(--violet-mid);
  text-decoration: underline;
  cursor: pointer;
  font-size: .85rem;
}

.error {
  color: #b3261e;
  min-height: 1.2em;
  margin: 0;
  font-size: .85rem;
}

/* --- app --- */

.app-shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  background: var(--violet-mid);
  border-right: 1px solid rgba(246,239,226,.15);
  display: flex;
  flex-direction: column;
  padding: 20px 16px;
  gap: 16px;
}

.sidebar-header {
  display: flex;
  align-items: center;
  gap: 10px;
}
.sidebar-header img { width: 28px; height: 20px; border-radius: 3px; }
.sidebar-header h1 { font-size: 1.1rem; color: var(--yellow); }

#posts-list {
  list-style: none;
  padding: 0;
  margin: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.post-item {
  background: rgba(246,239,226,.08);
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 10px 12px;
  cursor: pointer;
  color: var(--cream);
}
.post-item:hover { border-color: var(--yellow); }
.post-item.is-active { background: var(--violet-bright); }
.post-item h3 { font-size: .95rem; margin-bottom: 2px; }
.post-item .tags { font-size: .68rem; color: var(--yellow); font-family: var(--mono); }
.post-item .excerpt {
  font-size: .8rem;
  color: rgba(246,239,226,.7);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.post-item .meta { font-size: .7rem; color: rgba(246,239,226,.5); font-family: var(--mono); }

.new-post-toggle { align-self: flex-start; }

#new-post-box {
  background: var(--paper);
  color: var(--ink);
  border-radius: 8px;
  padding: 14px;
}

/* --- topbar + zone principale --- */

.main-column {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.topbar {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  padding: 14px 24px;
  border-bottom: 1px solid rgba(246,239,226,.1);
  position: relative;
}

.account-button {
  display: flex;
  align-items: center;
  gap: 8px;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--cream);
}
.account-button img {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
}

.account-menu {
  position: absolute;
  top: 56px;
  right: 24px;
  background: var(--paper);
  color: var(--ink);
  border-radius: 8px;
  box-shadow: 0 12px 30px rgba(0,0,0,.35);
  min-width: 180px;
  overflow: hidden;
  z-index: 10;
}
.account-menu button {
  display: block;
  width: 100%;
  text-align: left;
  padding: 10px 14px;
  border: none;
  background: none;
  cursor: pointer;
  color: var(--ink);
  font-size: .9rem;
}
.account-menu button:hover { background: var(--paper-dark); }

.account-panel {
  max-width: 420px;
  margin: 24px;
  background: var(--paper);
  color: var(--ink);
  border-radius: 12px;
  padding: 24px;
}

main {
  flex: 1;
  padding: 24px;
  overflow-y: auto;
}

.placeholder {
  color: rgba(246,239,226,.5);
  font-family: var(--mono);
  text-align: center;
  margin-top: 20vh;
}

#back-button {
  background: none;
  border: none;
  color: rgba(246,239,226,.6);
  cursor: pointer;
  padding: 0;
  margin-bottom: 16px;
  font-family: var(--mono);
  font-size: .8rem;
}

#thread-title { color: var(--yellow); margin-bottom: 16px; }

#thread-messages {
  list-style: none;
  padding: 0;
  margin: 0 0 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 700px;
}

.message {
  background: var(--paper);
  color: var(--ink);
  border-radius: 8px;
  padding: 10px 14px;
}
.message-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}
.message-header .avatar { width: 24px; height: 24px; border-radius: 50%; }
.message p { margin: 0; white-space: pre-wrap; }

#reply-form { max-width: 700px; }

@media (max-width: 720px) {
  .app-shell { flex-direction: column; }
  .sidebar { width: 100%; }
}
