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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: #1a1a2e;
  color: #e0e0e0;
  overflow-y: auto;
}

.hidden {
  display: none !important;
}

/* --- Header --- */

header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: #16213e;
  padding: 20px 20px;
  border-bottom: 1px solid #0f3460;
  text-align: center;
}

header h1 {
  font-size: 1.3rem;
  font-weight: 600;
  color: #a8d8ea;
  letter-spacing: 0.05em;
}

/* --- Tabs --- */

#tabs {
  display: flex;
  background: #16213e;
  border-bottom: 2px solid #0f3460;
  overflow-x: auto;
  overflow-y: hidden;
  position: sticky;
  top: 67px;
  z-index: 99;
}

.tab-btn {
  flex-shrink: 0;
  padding: 12px 20px;
  background: none;
  border: none;
  color: #888;
  font-size: 0.9rem;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: color 0.2s;
}

.tab-btn:hover {
  color: #e0e0e0;
}

.tab-btn.active {
  color: #a8d8ea;
  border-bottom-color: #a8d8ea;
}

/* --- Contenu principal --- */

main {
  max-width: 800px;
  margin: 0 auto;
  width: 100%;
}

.tab-content {
  display: none;
  padding: 20px 16px;
  padding-top: 0;
}

.tab-content.active {
  display: block;
}

.tab-inner {
  padding-top: 20px;
}

#tab-discussion .tab-inner {
  padding-top: 0;
}

/* --- Recherche --- */

#search-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
  flex-wrap: wrap;
  position: sticky;
  top: 111px;
  z-index: 98;
  margin: 0 -15px;
  padding: 15px;
  backdrop-filter: blur(5px) brightness(0.5);
  border-bottom: 2px solid #0f3460;
}

#search-input {
  flex: 1;
  min-width: 160px;
  padding: 8px 12px;
  background: #16213e;
  border: 1px solid #0f3460;
  border-radius: 6px;
  color: #e0e0e0;
  font-size: 16px;
  outline: none;
}

#search-input:focus {
  border-color: #a8d8ea;
}

#search-controls {
  display: flex;
  align-items: center;
  gap: 6px;
}

#search-counter {
  font-size: 0.8rem;
  color: #888;
  min-width: 40px;
  text-align: center;
}

#search-prev,
#search-next,
#search-clear {
  padding: 6px 10px;
  background: #0f3460;
  color: #a8d8ea;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.85rem;
  transition: background 0.2s;
}

#search-prev:hover,
#search-next:hover,
#search-clear:hover {
  background: #1a5276;
}

mark.search-highlight {
  background: #f39c12;
  color: #1a1a2e;
  border-radius: 2px;
  padding: 0 1px;
}

mark.search-highlight-active {
  background: #e74c3c;
  color: #fff;
}

/* --- Messages --- */

#messages-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
  flex: 1;
  overflow-y: auto;
  padding-top: 15px;
  padding-bottom: 45px;
}

.message {
  display: flex;
  gap: 12px;
}

.message-avatar {
  flex-shrink: 0;
}

.avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
}

.avatar-placeholder {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: #0f3460;
  color: #a8d8ea;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1rem;
}

.message-number {
  font-size: 14px;
  font-weight: 700;
  color: #e67e22;
}

.message-body {
  flex: 1;
}

.message-meta {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 4px;
}

.message-author {
  font-weight: 600;
  font-size: 0.95rem;
  color: #a8d8ea;
}

.message-time {
  font-size: 0.75rem;
  color: #555;
}

.message-content {
  font-size: 14px;
  line-height: 1.5;
  color: #ccc;
}

.message-images {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.msg-thumbnail {
  width: 80px;
  height: 60px;
  object-fit: cover;
  border-radius: 4px;
  cursor: pointer;
  border: 1px solid #0f3460;
}

/* --- Questions --- */

#questions-list {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.question-item {
  background: #16213e;
  border: 1px solid #0f3460;
  border-radius: 8px;
  padding: 16px;
}

.question-item label {
  display: block;
  font-size: 0.9rem;
  font-weight: 600;
  color: #a8d8ea;
  margin-bottom: 10px;
}

.question-row {
  display: flex;
  gap: 8px;
}

.question-row input {
  flex: 1;
  padding: 8px 12px;
  background: #1a1a2e;
  border: 1px solid #0f3460;
  border-radius: 6px;
  color: #e0e0e0;
  font-size: 16px;
  outline: none;
}

.question-row input:focus {
  border-color: #a8d8ea;
}

.question-row input.valid {
  border-color: #4caf50;
  color: #4caf50;
}

.question-row input:disabled {
  opacity: 0.7;
  cursor: not-allowed;
}

.question-row button {
  padding: 8px 16px;
  background: #0f3460;
  color: #a8d8ea;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.85rem;
  transition: background 0.2s;
}

.question-row button:hover {
  background: #1a5276;
}

.question-feedback {
  margin-top: 8px;
  font-size: 0.85rem;
  min-height: 18px;
}

.question-feedback.success { color: #4caf50; }
.question-feedback.error   { color: #e74c3c; }

/* --- Règles --- */

#rules-content {
  background: #16213e;
  border: 1px solid #0f3460;
  border-radius: 8px;
  padding: 20px;
  font-size: 0.92rem;
  line-height: 1.7;
  color: #ccc;
}

/* --- Placeholder --- */

.placeholder {
  color: #555;
  font-style: italic;
  margin-top: 20px;
  text-align: center;
}

/* --- Lightbox --- */

#lightbox {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
}

#lightbox-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  cursor: pointer;
}

#lightbox-img {
  position: relative;
  z-index: 1;
  max-width: 90vw;
  max-height: 85vh;
  border-radius: 8px;
  box-shadow: 0 8px 40px rgba(0,0,0,0.6);
  object-fit: contain;
}

/* --- Notes --- */

#notes-container {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

#notes-container label {
  font-size: 0.9rem;
  font-weight: 600;
  color: #a8d8ea;
}

#notes-textarea {
  width: 100%;
  min-height: 320px;
  padding: 14px;
  background: #16213e;
  border: 1px solid #0f3460;
  border-radius: 8px;
  color: #ccc;
  font-size: 16px;
  line-height: 1.6;
  resize: vertical;
  outline: none;
  font-family: inherit;
}

#notes-textarea:focus {
  border-color: #a8d8ea;
}

#notes-saved {
  font-size: 0.78rem;
  color: #4caf50;
  text-align: right;
  transition: opacity 0.4s;
}

/* --- Écran succès --- */

#success-screen {
  position: fixed;
  inset: 0;
  background: #0a0a1a;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}

.success-content {
  text-align: center;
  max-width: 500px;
}

.success-content img {
  max-width: 100%;
  border-radius: 12px;
  margin-bottom: 24px;
}

.success-content h1 {
  font-size: 1.8rem;
  color: #a8d8ea;
  margin-bottom: 16px;
}

.success-content p {
  font-size: 1rem;
  color: #ccc;
  line-height: 1.6;
}
