/* Variables */
:root {
  --primary-green: #2e7d32;
  --primary-green-hover: #1b5e20;
  --secondary-blue: #1976d2;
  --background-felt: #1a472a;
  --background-dark: #0d1f14;
  --text-light: #ffffff;
  --text-dark: #333333;
  --card-background: #f5f5dc;
  --border-color: #ddd;
  --success-green: #4caf50;
  --error-red: #f44336;
  --warning-yellow: #ffeb3b;
  --spade-color: #000000;
  --heart-color: #ff0000;
  --diamond-color: #ff0000;
  --club-color: #00b050;
  --header-bg: linear-gradient(90deg, #1a2744 0%, #243352 50%, #1a2744 100%);
  --section-bg: rgba(0, 0, 0, 0.3);
  --section-text: var(--text-light);
  --dropdown-bg: white;
  --dropdown-text: var(--text-dark);
  --dropdown-hover: #f5f5f5;
  --dropdown-divider: #e0e0e0;
}

/* Theme: Bleu nuit */
[data-theme="bleu-nuit"] {
  --primary-green: #c9a84c;
  --primary-green-hover: #b8943a;
  --secondary-blue: #5c8bc4;
  --background-felt: #1a2744;
  --background-dark: #0f1a2e;
  --text-light: #e8e8e8;
  --text-dark: #333333;
  --card-background: #f8f8ff;
  --border-color: #ccc;
  --header-bg: linear-gradient(90deg, #0f1a2e 0%, #1a2744 50%, #0f1a2e 100%);
  --section-bg: rgba(0, 0, 0, 0.35);
  --section-text: #e8e8e8;
  --dropdown-bg: #1e3050;
  --dropdown-text: #e8e8e8;
  --dropdown-hover: #263d5c;
  --dropdown-divider: rgba(255, 255, 255, 0.15);
}

/* Theme: Tapis vert */
[data-theme="tapis-vert"] {
  --primary-green: #5a8a5e;
  --primary-green-hover: #4a7a4e;
  --secondary-blue: #6a9a6e;
  --background-felt: #2a4d2e;
  --background-dark: #1a3320;
  --text-light: #f0ead6;
  --text-dark: #2c3e2c;
  --card-background: #f5f0e0;
  --border-color: #c8c0a8;
  --header-bg: linear-gradient(90deg, #1a3320 0%, #2a4d2e 50%, #1a3320 100%);
  --section-bg: rgba(0, 0, 0, 0.25);
  --section-text: #f0ead6;
  --dropdown-bg: #2a4d2e;
  --dropdown-text: #f0ead6;
  --dropdown-hover: #3a5d3e;
  --dropdown-divider: rgba(255, 255, 255, 0.15);
}

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

body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background: linear-gradient(135deg, var(--background-dark) 0%, var(--background-felt) 100%);
  min-height: 100vh;
  color: var(--text-light);
}

#app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Header */
.header {
  background: var(--header-bg);
  padding: 0.4rem 2rem;
  text-align: center;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.4);
}

.header-logo {
  display: flex;
  align-items: center;
}

.header-title {
  font-size: 1.3rem;
  font-weight: bold;
  color: #fff;
  text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.4);
  letter-spacing: 0.5px;
}

.header-version {
  font-size: 0.7rem;
  color: rgba(255, 255, 255, 0.5);
  margin-left: 0.4rem;
  align-self: flex-end;
  margin-bottom: 2px;
}

/* Main Content */
.main-content {
  flex: 1;
  padding: 1.5rem;
  max-width: 1400px;
  margin: 0 auto;
  width: 100%;
}

/* Theme Buttons Grid */
.theme-buttons {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

.theme-button {
  background: var(--primary-green);
  color: white;
  border: none;
  padding: 0.75rem 1rem;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

.theme-button:hover {
  background: var(--primary-green-hover);
  transform: translateY(-2px);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
}

.theme-button.active {
  background: var(--secondary-blue);
  box-shadow: 0 0 0 3px rgba(25, 118, 210, 0.5);
}

.theme-button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Problem Title Bar (Quiz) */
.problem-title-bar {
  background: linear-gradient(90deg, #1565c0 0%, #1976d2 50%, #1565c0 100%);
  padding: 0.5rem 1rem;
  border-radius: 8px;
  margin-bottom: 0.75rem;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  text-align: center;
}

.problem-title-text {
  color: white;
  font-size: 1.2rem;
  font-weight: 600;
  text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.3);
}

/* Quiz Page Layout - Fixed bottom buttons */
.quiz-page-container {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 130px); /* Viewport minus header and footer */
  max-height: calc(100vh - 130px);
}

.quiz-fixed-top {
  flex-shrink: 0;
}

.question-section-scroll {
  flex: 1;
  overflow-y: auto;
  min-height: 0; /* Important for flex scroll */
  padding-bottom: 0.5rem;
}

.quiz-bottom-bar {
  flex-shrink: 0;
  padding: 0.5rem 0;
  background: var(--background-dark);
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

/* Cards Display Area */
.quiz-area {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 1rem;
}

/* Hand Display - Bridge Diagram */
.hand-container {
  background: var(--card-background);
  border-radius: 10px;
  padding: 0.5rem;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

.hand-title {
  background: var(--warning-yellow);
  color: var(--text-dark);
  padding: 0.2rem 0.5rem;
  border: 1px solid #333;
  text-align: center;
  font-weight: bold;
  font-size: 0.9rem;
  margin-bottom: 0;
}

/* Bridge diagram layout - compact cross pattern with CSS Grid */
.bridge-diagram {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  grid-template-rows: auto auto auto;
  background: white;
  row-gap: 0;
}

.diagram-north {
  grid-column: 2;
  grid-row: 1;
  display: flex;
  justify-content: center;
  margin-bottom: -30px;
  z-index: 1;
}

.diagram-middle {
  grid-column: 1 / -1;
  grid-row: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.diagram-west {
  flex: 0 0 auto;
}

.diagram-center {
  flex: 1;
  min-width: 20px;
}

.diagram-east {
  flex: 0 0 auto;
}

.diagram-south {
  grid-column: 2;
  grid-row: 3;
  display: flex;
  justify-content: center;
  margin-top: -30px;
  z-index: 1;
}

/* Individual position hand */
.position-hand {
  border: 1px solid #333;
  background: white;
}

.position-header {
  background: #92D050;
  color: black;
  text-align: center;
  font-weight: bold;
  font-size: 0.8rem;
  padding: 0.1rem 0.3rem;
  border-bottom: 1px solid #333;
}

.hand-table {
  border-collapse: collapse;
  width: 100%;
}

.hand-table td {
  border: 1px solid #333;
  padding: 0 0.2rem;
  font-family: 'Segoe UI Symbol', Arial, sans-serif;
  line-height: 1.2;
}

.suit-cell {
  width: 18px;
  text-align: center;
  font-size: 0.9rem;
}

.cards-cell {
  min-width: 50px;
  color: var(--text-dark);
  font-weight: 500;
  font-size: 0.85rem;
}

.suit-symbol {
  font-weight: bold;
}

.suit-symbol.spades { color: var(--spade-color); }
.suit-symbol.hearts { color: var(--heart-color); }
.suit-symbol.diamonds { color: var(--diamond-color); }
.suit-symbol.clubs { color: var(--club-color); }

/* Bidding Table */
.bidding-container {
  background: var(--card-background);
  border-radius: 12px;
  padding: 1rem;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

.bidding-title {
  background: var(--warning-yellow);
  color: var(--text-dark);
  padding: 0.35rem 0.75rem;
  border-radius: 6px;
  text-align: center;
  font-weight: bold;
  font-size: 1rem;
  margin-bottom: 0.5rem;
}

.bidding-table {
  width: 100%;
  border-collapse: collapse;
  background: white;
  border-radius: 8px;
  overflow: hidden;
}

.bidding-table th {
  background: var(--success-green);
  color: white;
  padding: 0.4rem;
  font-weight: bold;
  font-size: 1rem;
}

.bidding-table td {
  padding: 0.35rem;
  text-align: center;
  border: 1px solid #ddd;
  font-size: 0.95rem;
  color: var(--text-dark);
}

.bidding-table .question-mark {
  color: #000;
  font-weight: bold;
  font-size: 1.2rem;
}

.bidding-additional-text {
  margin-top: 0.5rem;
  padding: 0.5rem 0.75rem;
  background: #fff3e0;
  border-radius: 6px;
  color: var(--text-dark);
  font-size: 0.9rem;
  font-weight: 500;
  font-style: italic;
}

/* Question/Answer Section */
.question-section {
  background: var(--card-background);
  border-radius: 12px;
  padding: 1rem;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

.question-label {
  color: var(--primary-green);
  font-weight: bold;
  font-size: 1rem;
  margin-bottom: 0.25rem;
}

.question-text {
  color: var(--text-dark);
  font-size: 1.1rem;
  font-weight: 500;
}

.answer-section {
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top: 1px solid #ddd;
}

.answer-section.hidden {
  display: none;
}

.answer-label {
  color: var(--secondary-blue);
  font-weight: bold;
  font-size: 1rem;
  margin-bottom: 0.25rem;
}

.answer-text {
  color: var(--text-dark);
  font-size: 1.1rem;
  font-weight: 600;
  background: #e8f5e9;
  padding: 0.5rem;
  border-radius: 6px;
  margin-bottom: 0.5rem;
}

.explanation-label {
  color: var(--secondary-blue);
  font-weight: bold;
  font-size: 1rem;
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top: 1px solid #ddd;
  margin-bottom: 0.25rem;
}

.explanation-text {
  color: var(--text-dark);
  font-size: 1rem;
  line-height: 1.6;
}

.sef-reference {
  margin-top: 0.5rem;
  padding: 0.4rem;
  background: #fff3e0;
  border-radius: 4px;
  font-size: 0.9rem;
  color: #e65100;
}

/* Buttons */
.button-row {
  display: flex;
  gap: 1rem;
  justify-content: center;
  margin-bottom: 0.75rem;
}

.btn {
  padding: 0.75rem 1.5rem;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.btn-primary {
  background: var(--secondary-blue);
  color: white;
}

.btn-primary:hover {
  background: #1565c0;
  transform: translateY(-2px);
}

.btn-success {
  background: var(--success-green);
  color: white;
}

.btn-success:hover {
  background: #388e3c;
}

.btn-danger {
  background: var(--error-red);
  color: white;
}

.btn-danger:hover {
  background: #d32f2f;
}

.btn-secondary {
  background: #757575;
  color: white;
}

.btn-secondary:hover {
  background: #616161;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.btn-sef {
  background: #1565c0;
  color: white;
}

.btn-sef:hover:not(:disabled) {
  background: #0d47a1;
}

/* Score Display */
.score-display {
  display: flex;
  justify-content: center;
  gap: 2rem;
  background: var(--section-bg);
  padding: 0.5rem 1rem;
  border-radius: 8px;
  margin-bottom: 0.75rem;
}

.score-item {
  text-align: center;
}

.score-label {
  font-size: 0.85rem;
  opacity: 0.9;
  margin-bottom: 0.25rem;
}

.score-value {
  font-size: 1.5rem;
  font-weight: bold;
}

.score-value.correct {
  color: var(--success-green);
}

.score-value.incorrect {
  color: var(--error-red);
}

.score-value.percentage {
  color: var(--warning-yellow);
}

/* Control Bar */
.control-bar {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  padding: 0.4rem 0.5rem;
  background: var(--section-bg);
  border-radius: 8px;
}

/* Modal */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal {
  background: white;
  border-radius: 12px;
  padding: 2rem;
  max-width: 600px;
  width: 90%;
  max-height: 90vh;
  overflow-y: auto;
  color: var(--text-dark);
}

.modal h2 {
  margin-bottom: 1.5rem;
  color: var(--primary-green);
}

.modal-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: #666;
}

/* Series Selection */
.series-list {
  max-height: 300px;
  overflow-y: auto;
  margin-bottom: 1rem;
}

.series-item {
  display: flex;
  align-items: center;
  padding: 0.75rem;
  border-bottom: 1px solid #eee;
}

.series-item:last-child {
  border-bottom: none;
}

.series-item input[type="checkbox"] {
  margin-right: 1rem;
  transform: scale(1.3);
}

.series-item label {
  flex: 1;
  cursor: pointer;
}

.series-count {
  color: #666;
  font-size: 0.9rem;
}

/* Mode Selection */
.mode-selection {
  display: flex;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.mode-option {
  flex: 1;
  padding: 1rem;
  border: 2px solid #ddd;
  border-radius: 8px;
  cursor: pointer;
  text-align: center;
  transition: all 0.2s ease;
}

.mode-option:hover {
  border-color: var(--primary-green);
}

.mode-option.selected {
  border-color: var(--primary-green);
  background: #e8f5e9;
}

.mode-option input {
  display: none;
}

/* Loading State */
.loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3rem;
}

.spinner {
  width: 50px;
  height: 50px;
  border: 4px solid rgba(255, 255, 255, 0.3);
  border-top-color: var(--primary-green);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Responsive */
@media (max-width: 900px) {
  .theme-buttons {
    grid-template-columns: repeat(2, 1fr);
  }

  .quiz-area {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 600px) {
  .theme-buttons {
    grid-template-columns: 1fr;
  }

  .score-display {
    flex-wrap: wrap;
    gap: 1rem;
  }

  .control-bar .btn {
    padding: 0.5rem 0.75rem;
    font-size: 0.8rem;
  }
}

/* Document Browser / PDF Viewer */
.document-page {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 140px);
}

.document-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
}

.document-header h2 {
  flex: 1;
  margin: 0;
}

.document-layout {
  flex: 1;
  display: flex;
  gap: 1rem;
  overflow: hidden;
}

.document-layout.with-viewer .document-sidebar {
  width: 300px;
  flex-shrink: 0;
}

.document-sidebar {
  background: var(--card-background);
  border-radius: 12px;
  padding: 1.5rem;
  color: var(--text-dark);
  overflow-y: auto;
}

.document-sidebar h3 {
  margin-bottom: 1rem;
  color: var(--primary-green);
  border-bottom: 2px solid var(--primary-green);
  padding-bottom: 0.5rem;
}

.folder-tree {
  list-style: none;
}

.folder-item, .file-item {
  padding: 0.5rem 0.75rem;
  cursor: pointer;
  border-radius: 6px;
  margin-bottom: 0.25rem;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.btn-upload-doc {
  font-size: 0.7rem;
  padding: 0.15rem 0.4rem;
  background: var(--primary-green);
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  white-space: nowrap;
  opacity: 0.85;
  transition: opacity 0.2s;
}

.btn-upload-doc:hover {
  opacity: 1;
}

.btn-upload-doc:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.file-item.selected .btn-upload-doc {
  background: white;
  color: var(--primary-green);
}

.doc-actions {
  display: flex;
  gap: 0.25rem;
  align-items: center;
}

.btn-delete-doc {
  font-size: 0.7rem;
  padding: 0.15rem 0.4rem;
  background: #e53935;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  white-space: nowrap;
  opacity: 0.85;
  transition: opacity 0.2s;
}

.btn-delete-doc:hover {
  opacity: 1;
}

.btn-delete-doc:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.file-item.selected .btn-delete-doc {
  background: #ffcdd2;
  color: #b71c1c;
}

.add-doc-item {
  border: 2px dashed #aaa;
  color: #777;
  justify-content: center;
  margin-top: 0.5rem;
  cursor: pointer;
  transition: all 0.2s;
}

.add-doc-item:hover {
  border-color: var(--primary-green);
  color: var(--primary-green);
  background: rgba(76, 175, 80, 0.05);
}

.folder-item:hover, .file-item:hover {
  background: #e0e0e0;
}

.file-item.selected {
  background: var(--primary-green);
  color: white;
}

.folder-children {
  margin-left: 1rem;
}

/* Tree view */
.tree-folder {
  padding: 0.5rem 0.75rem;
  cursor: pointer;
  border-radius: 6px;
  margin-bottom: 0.25rem;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  font-weight: 600;
}

.tree-folder:hover {
  background: #e0e0e0;
}

.tree-folder-label {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.tree-toggle {
  display: inline-block;
  width: 0.8rem;
  font-size: 0.65rem;
  text-align: center;
}

.tree-folder-icon {
  font-size: 1rem;
}

.tree-file-label {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.tree-file-icon {
  font-size: 1rem;
}

.tree-folder-children {
  /* indentation is handled by inline paddingLeft */
}

.tree-folder-wrapper {
  /* wrapper for folder + children */
}

/* Upload progress */
.upload-progress-banner {
  background: #e3f2fd;
  border: 1px solid #90caf9;
  border-radius: 8px;
  padding: 0.5rem 1rem;
  margin-bottom: 0.5rem;
  color: #1565c0;
}

.upload-progress-text {
  font-size: 0.85rem;
  margin-bottom: 0.35rem;
}

.upload-progress-bar-container {
  background: #bbdefb;
  border-radius: 4px;
  height: 6px;
  overflow: hidden;
}

.upload-progress-bar {
  background: #1976d2;
  height: 100%;
  border-radius: 4px;
  transition: width 0.3s ease;
}

.no-documents {
  color: #666;
  font-style: italic;
}

.pdf-viewer {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: #333;
  border-radius: 12px;
  overflow: hidden;
}

.pdf-title {
  padding: 0.75rem 1rem;
  background: rgba(0, 0, 0, 0.5);
  color: white;
  font-weight: 600;
}

.pdf-frame {
  flex: 1;
  width: 100%;
  border: none;
}

.error-banner {
  background: #f44336;
  color: white;
  padding: 1rem;
  border-radius: 8px;
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* ===== HOME PAGE LAYOUT ===== */
.home-layout {
  display: grid;
  grid-template-columns: 1fr 380px;
  gap: 2rem;
  min-height: calc(100vh - 200px);
}

.home-left {
  display: flex;
  align-items: flex-start;
}

.home-right {
  display: flex;
  align-items: flex-start;
}

/* Welcome Card */
.welcome-card {
  background: linear-gradient(145deg, rgba(255,255,255,0.1) 0%, rgba(255,255,255,0.05) 100%);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 20px;
  padding: 2.5rem;
  width: 100%;
  backdrop-filter: blur(10px);
}

.welcome-header {
  text-align: center;
  margin-bottom: 2rem;
  padding-bottom: 2rem;
  border-bottom: 1px solid rgba(255,255,255,0.1);
}

.welcome-icon {
  margin-bottom: 1rem;
}

.card-suits {
  font-size: 2.5rem;
  display: flex;
  justify-content: center;
  gap: 0.5rem;
}

.suit-spade { color: #1a1a2e; text-shadow: 0 0 10px rgba(0,0,0,0.5); }
.suit-heart { color: #e63946; text-shadow: 0 0 10px rgba(230,57,70,0.5); }
.suit-diamond { color: #e63946; text-shadow: 0 0 10px rgba(230,57,70,0.5); }
.suit-club { color: #2d6a4f; text-shadow: 0 0 10px rgba(45,106,79,0.5); }

.welcome-header h2 {
  font-size: 2rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
  background: linear-gradient(135deg, #ffffff 0%, #a8dadc 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.welcome-subtitle {
  font-size: 1.1rem;
  color: rgba(255,255,255,0.7);
  font-weight: 400;
}

.welcome-problem-count {
  font-size: 1.05rem;
  color: rgba(255,255,255,0.85);
  font-weight: 500;
  margin-top: 0.25rem;
}

.welcome-content {
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

/* Feature List */
.feature-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.feature-item {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem;
  background: rgba(255,255,255,0.05);
  border-radius: 12px;
  transition: all 0.3s ease;
}

.feature-item:hover {
  background: rgba(255,255,255,0.1);
  transform: translateX(5px);
}

.feature-number {
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, var(--primary-green) 0%, var(--primary-green-hover) 100%);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  font-size: 1rem;
  flex-shrink: 0;
}

.feature-text {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.feature-text strong {
  font-size: 1rem;
  color: #fff;
}

.feature-text span {
  font-size: 0.85rem;
  color: rgba(255,255,255,0.6);
}

/* Documents Button */
.documents-section {
  margin-top: 1rem;
}

/* Home page action buttons - shared base */
.home-btn {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem 1.25rem;
  border-radius: 12px;
  color: white;
  cursor: pointer;
  transition: all 0.3s ease;
  text-align: left;
  margin-bottom: 0.5rem;
}

.home-btn:hover {
  transform: translateX(5px);
}

.home-btn-about {
  background: rgba(100, 140, 180, 0.18);
  border: 1px solid rgba(100, 140, 180, 0.35);
}
.home-btn-about:hover {
  background: rgba(100, 140, 180, 0.30);
  border-color: rgba(100, 140, 180, 0.55);
}

.home-btn-guide {
  background: rgba(72, 166, 153, 0.18);
  border: 1px solid rgba(72, 166, 153, 0.35);
}
.home-btn-guide:hover {
  background: rgba(72, 166, 153, 0.30);
  border-color: rgba(72, 166, 153, 0.55);
}

.home-btn-docs {
  background: rgba(92, 124, 210, 0.18);
  border: 1px solid rgba(92, 124, 210, 0.35);
}
.home-btn-docs:hover {
  background: rgba(92, 124, 210, 0.30);
  border-color: rgba(92, 124, 210, 0.55);
}

.home-btn-editor {
  background: rgba(156, 110, 180, 0.18);
  border: 1px solid rgba(156, 110, 180, 0.35);
}
.home-btn-editor:hover {
  background: rgba(156, 110, 180, 0.30);
  border-color: rgba(156, 110, 180, 0.55);
}

.btn-icon {
  font-size: 2rem;
}

.btn-text {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.btn-text strong {
  font-size: 1.1rem;
}

.btn-text span {
  font-size: 0.85rem;
  opacity: 0.85;
}

/* Stats Section - Last Quiz Results (inside welcome card) */
.stats-section {
  margin-top: 1.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid rgba(255,255,255,0.1);
}

.stats-title {
  font-size: 1.2rem;
  color: #fff;
  margin-bottom: 1rem;
  text-align: center;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid rgba(255,255,255,0.1);
}

.stats-content {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.stats-theme {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem;
  background: rgba(255,255,255,0.05);
  border-radius: 8px;
}

.stats-label {
  color: rgba(255,255,255,0.7);
  font-size: 0.9rem;
}

.stats-value {
  color: #fff;
  font-weight: 600;
}

.stats-score {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 1.5rem;
  padding: 1rem;
  background: rgba(76, 175, 80, 0.1);
  border-radius: 12px;
  border: 1px solid rgba(76, 175, 80, 0.3);
}

.stats-score-main {
  display: flex;
  align-items: baseline;
  gap: 0.25rem;
  font-size: 1.8rem;
  font-weight: bold;
}

.stats-correct {
  color: #4caf50;
}

.stats-separator {
  color: rgba(255,255,255,0.5);
}

.stats-total {
  color: #fff;
}

.stats-percentage {
  font-size: 2rem;
  font-weight: bold;
  color: #4caf50;
}

.stats-details {
  display: flex;
  justify-content: space-around;
  gap: 1rem;
}

.stats-detail {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9rem;
}

.stats-detail.correct {
  color: #4caf50;
}

.stats-detail.incorrect {
  color: #f44336;
}

.stats-icon {
  font-size: 1rem;
  font-weight: bold;
}

/* ==================== Upload Status Banner ==================== */

.upload-status-banner {
  color: white;
  padding: 0.5rem 1rem;
  border-radius: 6px;
  margin-bottom: 0.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.upload-status-banner.success {
  background: #4caf50;
}

.upload-status-banner.error {
  background: #f44336;
}

.upload-status-banner .upload-status-dismiss {
  background: none;
  border: none;
  color: white;
  cursor: pointer;
  font-size: 1.2rem;
}

/* ==================== Custom Search Section ==================== */

/* Custom Search Page */
.custom-search-page {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 180px);
}

.custom-search-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
}

.custom-search-header h2 {
  margin: 0;
  color: white;
  font-size: 1.5rem;
  flex: 1;
}

.btn-help-search {
  white-space: nowrap;
  font-size: 0.85rem;
}

.custom-search-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.custom-search-columns {
  flex: 1;
  display: grid;
  grid-template-columns: 3fr 2fr;
  gap: 1rem;
  min-height: 0;
}

.custom-search-col {
  display: flex;
  flex-direction: column;
  background: linear-gradient(145deg, rgba(255,255,255,0.1) 0%, rgba(255,255,255,0.05) 100%);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 12px;
  padding: 1rem;
  backdrop-filter: blur(10px);
  overflow: hidden;
}

.custom-search-col-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
}

.custom-search-col-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: rgba(255,255,255,0.9);
}

.search-add-all {
  background: none;
  border: 1px solid var(--primary-green);
  color: var(--primary-green);
  font-size: 0.75rem;
  padding: 0.25rem 0.6rem;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s;
}

.search-add-all:hover {
  background: var(--primary-green);
  color: white;
}

@media (max-width: 768px) {
  .custom-search-columns {
    grid-template-columns: 1fr;
  }
}

/* Custom Search Button in theme list */
.custom-search-button {
  border-style: dashed !important;
  border-color: rgba(46, 125, 50, 0.5) !important;
  background: rgba(46, 125, 50, 0.08) !important;
}

.custom-search-button:hover {
  border-color: rgba(46, 125, 50, 0.8) !important;
  background: rgba(46, 125, 50, 0.15) !important;
}

/* Mode toggle button in header */
.custom-search-header-right {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.btn-mode-toggle {
  font-size: 0.85rem;
  white-space: nowrap;
}

/* ===== Wizard (Assistant mode) ===== */
.wizard-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 1rem 1rem 2rem;
  overflow-y: auto;
  flex: 1;
}

/* Step indicator bar */
.wizard-step-indicator {
  display: flex;
  align-items: center;
  gap: 0;
  margin-bottom: 2rem;
  width: 100%;
  max-width: 500px;
  justify-content: center;
}

.wizard-step-dot {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.25);
  background: rgba(0,0,0,0.2);
  color: rgba(255,255,255,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  font-weight: 600;
  flex-shrink: 0;
  transition: all 0.2s;
}

.wizard-step-dot.active {
  border-color: var(--primary-green);
  background: var(--primary-green);
  color: white;
  box-shadow: 0 0 8px rgba(46,125,50,0.4);
}

.wizard-step-dot.done {
  border-color: var(--primary-green);
  background: rgba(46,125,50,0.2);
  color: var(--primary-green);
  cursor: pointer;
}

.wizard-step-dot.done:hover {
  background: rgba(46,125,50,0.35);
}

.wizard-step-line {
  flex: 1;
  height: 2px;
  background: rgba(255,255,255,0.15);
  min-width: 20px;
  max-width: 60px;
  transition: background 0.2s;
}

.wizard-step-line.done {
  background: var(--primary-green);
}

/* Step card */
.wizard-step-card {
  width: 100%;
  max-width: 700px;
  background: rgba(0,0,0,0.2);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 16px;
  padding: 2rem;
  backdrop-filter: blur(10px);
}

.wizard-step-title {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--text-light);
  margin: 0 0 0.5rem;
}

.wizard-step-subtitle {
  font-size: 0.9rem;
  color: rgba(255,255,255,0.6);
  margin: 0 0 1.5rem;
}

/* Navigation */
.wizard-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.wizard-nav-right {
  display: flex;
  gap: 0.75rem;
  align-items: center;
}

.wizard-step-examples {
  font-size: 0.85rem;
  color: rgba(255,255,255,0.5);
  margin: -0.75rem 0 1.25rem;
}

.wizard-example {
  color: var(--primary-green);
  cursor: pointer;
  text-decoration: underline;
  text-decoration-style: dotted;
  text-underline-offset: 2px;
}

.wizard-example:hover {
  color: #66bb6a;
  text-decoration-style: solid;
}

.wizard-link-btn {
  background: none;
  border: none;
  color: rgba(255,255,255,0.5);
  font-size: 0.85rem;
  cursor: pointer;
  text-decoration: underline;
  padding: 0.4rem 0;
}

.wizard-link-btn:hover {
  color: rgba(255,255,255,0.8);
}

/* Theme grid */
.wizard-theme-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
}

.wizard-theme-grid .theme-button {
  text-align: left;
  padding: 0.6rem 0.8rem;
  font-size: 0.85rem;
}

.wizard-theme-grid .theme-button.selected {
  border-color: var(--primary-green) !important;
  background: rgba(46,125,50,0.2) !important;
  color: white;
}

/* Level options */
.wizard-level-options {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.wizard-level-option {
  display: block;
  width: 100%;
  padding: 0.9rem 1rem;
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 10px;
  background: rgba(0,0,0,0.15);
  color: var(--text-light);
  font-size: 0.95rem;
  cursor: pointer;
  transition: all 0.15s;
  text-align: left;
}

.wizard-level-option:hover {
  border-color: rgba(255,255,255,0.3);
  background: rgba(255,255,255,0.08);
}

.wizard-level-option.selected {
  border-color: var(--primary-green);
  background: rgba(46,125,50,0.2);
}

/* Results list in wizard */
.wizard-results-list {
  max-height: 400px;
  overflow-y: auto;
  border-radius: 8px;
  background: rgba(0,0,0,0.15);
}

/* No results */
.wizard-no-results {
  text-align: center;
  padding: 2rem 1rem;
  color: rgba(255,255,255,0.5);
}

.wizard-no-results p {
  margin: 0 0 1rem;
}

/* Post-add confirmation */
.wizard-post-add {
  text-align: center;
  padding: 2rem 1rem;
}

.wizard-post-add-icon {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--primary-green);
  color: white;
  font-size: 1.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 1rem;
}

.wizard-post-add-text {
  font-size: 1.05rem;
  color: var(--text-light);
  margin: 0 0 0.25rem;
}

.wizard-post-add-total {
  font-size: 0.85rem;
  color: rgba(255,255,255,0.5);
  margin: 0 0 1.5rem;
}

.wizard-post-add-actions {
  display: flex;
  gap: 0.75rem;
  justify-content: center;
}

/* Responsive wizard */
@media (max-width: 768px) {
  .wizard-theme-grid {
    grid-template-columns: 1fr;
  }

  .wizard-step-card {
    padding: 1.25rem;
  }

  .wizard-nav-right {
    flex-direction: column;
    gap: 0.5rem;
  }

  .wizard-post-add-actions {
    flex-direction: column;
  }

  .custom-search-header-right {
    flex-direction: column;
    gap: 0.25rem;
  }
}

.search-modal-input {
  width: 100%;
  padding: 0.7rem 0.85rem;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.2);
  background: rgba(0,0,0,0.2);
  color: var(--text-light);
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.2s;
  margin-bottom: 0.75rem;
  box-sizing: border-box;
}

.search-modal-input::placeholder {
  color: rgba(255,255,255,0.5);
}

.search-modal-input:focus {
  border-color: var(--primary-green);
  box-shadow: 0 0 0 2px rgba(46, 125, 50, 0.3);
}

.search-filters-row {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.search-body-checkbox {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.85rem;
  color: var(--text-muted);
  cursor: pointer;
  margin-top: 0.25rem;
}

.search-body-checkbox input[type="checkbox"] {
  accent-color: var(--primary);
  cursor: pointer;
}

.search-modal-select {
  flex: 1;
  padding: 0.6rem 0.5rem;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.2);
  background: rgba(0,0,0,0.2);
  color: var(--text-light);
  font-size: 0.85rem;
  outline: none;
  cursor: pointer;
}

.search-modal-select option {
  background: var(--background-felt);
  color: var(--text-light);
}

.search-modal-select:focus {
  border-color: var(--primary-green);
  box-shadow: 0 0 0 2px rgba(46, 125, 50, 0.3);
}

/* Subtheme filter panel (multi-select checkboxes) */
.subtheme-filter-panel {
  background: rgba(0, 0, 0, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  padding: 0.5rem 0.75rem;
  margin-bottom: 0.75rem;
}

.subtheme-filter-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.4rem;
  font-size: 0.85rem;
  color: rgba(255, 255, 255, 0.7);
}

.subtheme-toggle-all {
  background: none;
  border: none;
  color: var(--primary-green);
  cursor: pointer;
  font-size: 0.8rem;
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
}

.subtheme-toggle-all:hover {
  text-decoration: underline;
}

.subtheme-checkboxes {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem 0.75rem;
  max-height: 7.5rem;
  overflow-y: auto;
}

.subtheme-checkbox-item {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.82rem;
  color: var(--text-light);
  cursor: pointer;
  max-width: 18rem;
  white-space: nowrap;
}

.subtheme-checkbox-item input[type="checkbox"] {
  accent-color: var(--primary-green);
  cursor: pointer;
  flex-shrink: 0;
}

.subtheme-checkbox-label {
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Search Results */
.search-results {
  flex: 1;
  overflow-y: auto;
  border-radius: 8px;
  background: rgba(0,0,0,0.15);
}

.search-results-status {
  padding: 0.75rem;
  text-align: center;
  color: rgba(255,255,255,0.5);
  font-size: 0.85rem;
}

.search-result-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  transition: background 0.15s;
}

.search-result-item:last-child {
  border-bottom: none;
}

.search-result-item:hover {
  background: rgba(255,255,255,0.08);
}

.search-result-item.already-added {
  opacity: 0.5;
}

.search-result-info {
  flex: 1;
  min-width: 0;
}

.search-result-title {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-light);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.search-result-meta {
  font-size: 0.75rem;
  color: rgba(255,255,255,0.5);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.search-result-add {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 1px solid var(--primary-green);
  background: rgba(46, 125, 50, 0.1);
  color: var(--primary-green);
  font-size: 1.1rem;
  font-weight: bold;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.15s;
  line-height: 1;
}

.search-result-add:hover:not(:disabled) {
  background: var(--primary-green);
  color: white;
}

.search-result-add:disabled {
  cursor: default;
  border-color: rgba(255,255,255,0.15);
  background: rgba(255,255,255,0.05);
  color: rgba(255,255,255,0.3);
}

/* Selected Problems */
.selected-problems {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.selected-problems-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: rgba(255,255,255,0.9);
}

.selected-problems-clear {
  background: none;
  border: none;
  color: rgba(255,255,255,0.5);
  font-size: 0.75rem;
  cursor: pointer;
  text-decoration: underline;
  padding: 0;
}

.selected-problems-clear:hover {
  color: rgba(255,255,255,0.8);
}

.selected-problems-list {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.selected-problem-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0.5rem;
  background: rgba(255,255,255,0.05);
  border-radius: 6px;
}

.selected-problem-info {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.selected-problem-title {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-light);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.selected-problem-meta {
  font-size: 0.7rem;
  color: rgba(255,255,255,0.5);
  white-space: nowrap;
  flex-shrink: 0;
}

.selected-problem-remove {
  background: none;
  border: none;
  color: rgba(255,255,255,0.4);
  font-size: 0.85rem;
  cursor: pointer;
  padding: 0.1rem 0.3rem;
  border-radius: 4px;
  transition: all 0.15s;
  flex-shrink: 0;
  line-height: 1;
}

.selected-problem-remove:hover {
  color: var(--error-red);
  background: rgba(244, 67, 54, 0.1);
}

/* Custom Quiz Launch */
.custom-quiz-launch {
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid rgba(255,255,255,0.1);
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.custom-quiz-mode {
  display: flex;
  gap: 0.5rem;
}

.custom-mode-option {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.5rem;
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.85rem;
  color: rgba(255,255,255,0.6);
  transition: all 0.2s;
}

.custom-mode-option input {
  display: none;
}

.custom-mode-option:hover {
  border-color: rgba(255,255,255,0.3);
}

.custom-mode-option.selected {
  border-color: var(--primary-green);
  background: rgba(46, 125, 50, 0.2);
  color: var(--text-light);
}

.custom-quiz-start {
  width: 100%;
  justify-content: center;
  padding: 0.65rem 1rem;
  font-size: 0.95rem;
}

/* Themes Card */
.themes-card {
  background: linear-gradient(145deg, rgba(255,255,255,0.1) 0%, rgba(255,255,255,0.05) 100%);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 20px;
  padding: 1.5rem;
  width: 100%;
  backdrop-filter: blur(10px);
}

.themes-title {
  text-align: center;
  font-size: 1.2rem;
  font-weight: 600;
  margin-bottom: 1.25rem;
  color: rgba(255,255,255,0.9);
}

.theme-buttons-vertical {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.theme-button-new {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 1rem;
  background: linear-gradient(135deg, var(--primary-green) 0%, var(--primary-green-hover) 100%);
  border: none;
  border-radius: 10px;
  color: white;
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: left;
}

.theme-button-new:hover:not(.disabled) {
  transform: translateX(5px);
  box-shadow: 0 4px 15px rgba(46, 125, 50, 0.4);
}

.theme-button-new.active {
  background: linear-gradient(135deg, var(--secondary-blue) 0%, #1565c0 100%);
  box-shadow: 0 0 0 2px rgba(255,255,255,0.3);
}

.theme-button-new.disabled {
  opacity: 0.5;
  cursor: not-allowed;
  background: linear-gradient(135deg, #666 0%, #555 100%);
}

.theme-number {
  width: 28px;
  height: 28px;
  background: rgba(255,255,255,0.2);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  font-size: 0.9rem;
  flex-shrink: 0;
}

.theme-name {
  flex: 1;
  font-weight: 600;
  font-size: 0.95rem;
}

.theme-count {
  font-size: 0.75rem;
  background: rgba(255,255,255,0.2);
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  opacity: 0.9;
}

.theme-empty {
  font-size: 0.7rem;
  font-style: italic;
  opacity: 0.7;
}

/* Footer */
.app-footer {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 1.5rem;
  flex-wrap: wrap;
  padding: 0.75rem 2rem;
  color: rgba(255,255,255,0.4);
  font-size: 0.8rem;
  border-top: 1px solid rgba(255,255,255,0.1);
  margin-top: auto;
}

.footer-links {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.footer-links button {
  background: none;
  border: none;
  color: rgba(255,255,255,0.5);
  font-size: 0.8rem;
  cursor: pointer;
  padding: 0;
  text-decoration: underline;
  transition: color 0.2s;
}

.footer-links button:hover {
  color: rgba(255,255,255,0.8);
}

.footer-separator {
  color: rgba(255,255,255,0.3);
}

/* Legal Pages */
.legal-page {
  max-width: 900px;
  margin: 0 auto;
}

.legal-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid rgba(255,255,255,0.1);
}

.legal-header h2 {
  flex: 1;
  margin: 0;
}

.legal-content {
  background: rgba(255,255,255,0.05);
  border-radius: 8px;
  padding: 2rem;
}

.legal-text section {
  margin-bottom: 2rem;
}

.legal-text section:last-child {
  margin-bottom: 0;
}

.legal-text h3 {
  color: var(--warning-yellow);
  margin-bottom: 0.75rem;
  font-size: 1.1rem;
}

.legal-text p {
  margin-bottom: 0.75rem;
  line-height: 1.6;
  color: rgba(255,255,255,0.85);
}

.legal-text ul {
  margin: 0.5rem 0 0.75rem 1.5rem;
  line-height: 1.6;
  color: rgba(255,255,255,0.85);
}

.legal-text li {
  margin-bottom: 0.4rem;
}

.legal-text a {
  color: var(--secondary-blue);
  text-decoration: none;
}

.legal-text a:hover {
  text-decoration: underline;
}

@media (max-width: 768px) {
  .app-footer {
    flex-direction: column;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
  }

  .legal-content {
    padding: 1rem;
  }

  .legal-header {
    flex-direction: column;
    align-items: flex-start;
  }
}

/* Responsive for Home Layout */
@media (max-width: 900px) {
  .home-layout {
    grid-template-columns: 1fr;
    gap: 1.5rem;
  }

  .home-right {
    order: -1;
  }

  .theme-buttons-vertical {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 600px) {
  .theme-buttons-vertical {
    grid-template-columns: 1fr;
  }

  .welcome-card {
    padding: 1.5rem;
  }

  .card-suits {
    font-size: 2rem;
  }

  .welcome-header h2 {
    font-size: 1.5rem;
  }

  .search-filters-row {
    flex-direction: column;
  }
}

/* Legacy Welcome Screen - kept for compatibility */
.welcome-screen {
  text-align: center;
  padding: 3rem;
}

.welcome-screen h2 {
  font-size: 1.8rem;
  margin-bottom: 1rem;
}

.welcome-screen p {
  font-size: 1.1rem;
  opacity: 0.9;
  margin-bottom: 2rem;
}

.welcome-instructions {
  background: rgba(0, 0, 0, 0.2);
  padding: 1.5rem;
  border-radius: 8px;
  text-align: left;
  max-width: 600px;
  margin: 0 auto;
}

.welcome-instructions ol {
  margin-left: 1.5rem;
}

.welcome-instructions li {
  margin-bottom: 0.5rem;
}

/* ==================== Editor Page Styles ==================== */

.editor-page {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 120px);
  gap: 1rem;
}

.editor-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(0, 0, 0, 0.3);
  padding: 1rem 1.5rem;
  border-radius: 12px;
}

.editor-header h1 {
  font-size: 1.5rem;
  margin: 0;
}

.editor-actions {
  display: flex;
  gap: 0.75rem;
}

.btn-back {
  background: rgba(255, 255, 255, 0.1);
  color: white;
  border: 1px solid rgba(255, 255, 255, 0.2);
  padding: 0.5rem 1rem;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-back:hover {
  background: rgba(255, 255, 255, 0.2);
}

.btn-import {
  background: #ff9800;
  color: white;
  border: none;
  padding: 0.5rem 1rem;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
  transition: all 0.2s;
}

.btn-import:hover {
  background: #f57c00;
}

.btn-import:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.import-result {
  background: rgba(76, 175, 80, 0.2);
  border: 1px solid rgba(76, 175, 80, 0.5);
  padding: 0.75rem 1rem;
  border-radius: 8px;
  display: flex;
  align-items: center;
  gap: 1rem;
}

.import-errors {
  color: #ff6b6b;
}

.btn-close {
  background: transparent;
  border: none;
  color: white;
  cursor: pointer;
  font-size: 1.2rem;
  margin-left: auto;
}

.editor-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  padding: 0.75rem 1rem;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 8px;
  font-size: 0.9rem;
}

.stat-item {
  opacity: 0.8;
}

.editor-filters {
  display: flex;
  gap: 1rem;
  padding: 0.75rem 1rem;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 8px;
}

.filter-group {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.filter-group label {
  font-weight: 500;
}

.filter-group select,
.filter-group input {
  padding: 0.5rem;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(0, 0, 0, 0.3);
  color: white;
  min-width: 200px;
}

.editor-content {
  flex: 1;
  display: flex;
  gap: 1rem;
  overflow: hidden;
}

.editor-sidebar {
  width: 350px;
  flex-shrink: 0;
  overflow-y: auto;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 12px;
  padding: 1rem;
}

.editor-main {
  flex: 1;
  overflow-y: auto;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 12px;
  padding: 1.5rem;
}

.editor-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  opacity: 0.6;
  font-size: 1.1rem;
}

/* Problem List */
.problem-list {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.problem-list.loading,
.problem-list.empty {
  text-align: center;
  padding: 2rem;
  opacity: 0.7;
}

.problem-list.empty .hint {
  font-size: 0.9rem;
  margin-top: 0.5rem;
  opacity: 0.7;
}

.problem-list-theme-header {
  padding: 0.4rem 0.75rem;
  margin-top: 0.5rem;
  font-weight: bold;
  font-size: 0.85rem;
  color: #1a2744;
  background: rgba(26, 39, 68, 0.08);
  border-left: 3px solid #1a2744;
  border-radius: 0 4px 4px 0;
}

.problem-list-theme-header:first-child {
  margin-top: 0;
}

.problem-list-subtheme-header {
  padding: 0.25rem 0.75rem;
  margin-top: 0.25rem;
  font-size: 0.8rem;
  font-style: italic;
  color: #48a699;
  border-left: 2px solid #48a699;
  border-radius: 0 4px 4px 0;
}

.problem-item {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  padding: 0.4rem 0.75rem;
  cursor: pointer;
  transition: all 0.2s;
}

.problem-item:hover {
  background: rgba(255, 255, 255, 0.1);
}

.problem-item.selected {
  background: rgba(25, 118, 210, 0.3);
  border-color: rgba(25, 118, 210, 0.5);
}

.problem-item-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.problem-item-title {
  font-weight: 600;
  font-size: 0.95rem;
  color: white;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  min-width: 0;
}

.problem-answer-preview {
  color: rgba(255, 255, 255, 0.5);
  font-size: 0.85rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 80px;
  flex-shrink: 0;
  text-align: right;
}

.problem-subtheme {
  font-size: 0.8rem;
  opacity: 0.5;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  min-width: 0;
}

.btn-icon.delete {
  background: transparent;
  border: none;
  color: #ff6b6b;
  cursor: pointer;
  font-weight: bold;
  padding: 0.15rem 0.4rem;
  font-size: 1rem;
  opacity: 0;
  transition: opacity 0.2s;
  flex-shrink: 0;
}

.problem-item:hover .btn-icon.delete {
  opacity: 1;
}

/* Problem Form */
.problem-form {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.form-section {
  background: rgba(255, 255, 255, 0.05);
  border-radius: 12px;
  padding: 1.25rem;
}

.form-title-section {
  background: linear-gradient(135deg, rgba(25, 118, 210, 0.2) 0%, rgba(25, 118, 210, 0.1) 100%);
  border: 1px solid rgba(25, 118, 210, 0.3);
}

.form-title-section label {
  font-size: 1.1rem;
  color: #90caf9;
}

.title-input {
  font-size: 1.2rem !important;
  font-weight: 600;
  padding: 1rem !important;
}

.form-section h3 {
  margin-bottom: 1rem;
  font-size: 1.1rem;
  color: #90caf9;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  padding-bottom: 0.5rem;
}

.form-row {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}

.form-group {
  flex: 1;
  min-width: 200px;
  margin-bottom: 1rem;
}

.form-group label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 500;
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 0.75rem;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(0, 0, 0, 0.3);
  color: white;
  font-size: 1rem;
}

.form-group textarea {
  resize: vertical;
  min-height: 100px;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--secondary-blue);
  box-shadow: 0 0 0 2px rgba(25, 118, 210, 0.3);
}

.problem-form input::placeholder,
.problem-form textarea::placeholder,
.suit-input::placeholder,
.bid-input::placeholder {
  color: rgba(255,255,255,0.3);
  font-style: italic;
}

/* Hands Grid for Editor */
.hands-grid {
  display: grid;
  grid-template-areas:
    ". north ."
    "west . east"
    ". south .";
  grid-template-columns: 1fr 1fr 1fr;
  gap: 1rem;
  justify-items: center;
}

.hand-position.north { grid-area: north; }
.hand-position.south { grid-area: south; }
.hand-position.east { grid-area: east; }
.hand-position.west { grid-area: west; }

/* Hand Editor */
.hand-editor {
  background: rgba(0, 0, 0, 0.3);
  border-radius: 10px;
  padding: 1rem;
  min-width: 180px;
}

.hand-editor-header {
  text-align: center;
  font-weight: bold;
  margin-bottom: 0.75rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.hand-editor-suits {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.suit-input-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.suit-symbol {
  font-size: 1.2rem;
  width: 24px;
  text-align: center;
}

.suit-symbol.spade { color: #fff; }
.suit-symbol.heart { color: #ff0000; }
.suit-symbol.diamond { color: #ff0000; }
.suit-symbol.club { color: #00b050; }

.suit-input {
  flex: 1;
  padding: 0.5rem;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.1);
  color: white;
  font-family: monospace;
  font-size: 1rem;
}

/* Bidding Editor */
.bidding-editor {
  background: rgba(0, 0, 0, 0.2);
  border-radius: 10px;
  padding: 1rem;
}

.bidding-editor-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.dealer-selector {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.dealer-selector select {
  padding: 0.4rem;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(0, 0, 0, 0.3);
  color: white;
}

.bidding-table-editor {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 1rem;
}

.bidding-table-editor th {
  padding: 0.5rem;
  background: rgba(255, 255, 255, 0.1);
  font-weight: 600;
}

.bidding-table-editor td {
  padding: 0.25rem;
}

.bid-input {
  width: 100%;
  padding: 0.5rem;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.1);
  color: white;
  text-align: center;
  font-family: monospace;
}

.bidding-row-controls {
  display: flex;
  gap: 0.5rem;
  justify-content: center;
}

.btn-small {
  padding: 0.4rem 0.75rem;
  font-size: 0.85rem;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: white;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-small:hover {
  background: rgba(255, 255, 255, 0.2);
}

.btn-small:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Form Actions */
.form-actions {
  display: flex;
  gap: 1rem;
  justify-content: flex-end;
  padding-top: 1rem;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.btn-primary {
  background: var(--primary-green);
  color: white;
  border: none;
  padding: 0.75rem 1.5rem;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-primary:hover {
  background: var(--primary-green-hover);
}

.btn-primary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* Mode d'emploi View */
.mode-emploi-container {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 180px);
}

.mode-emploi-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
}

.mode-emploi-header h2 {
  margin: 0;
  color: white;
  font-size: 1.5rem;
}

.mode-emploi-content {
  flex: 1;
  background: white;
  border-radius: 12px;
  overflow: hidden;
}

.mode-emploi-frame {
  width: 100%;
  height: 100%;
  border: none;
}

/* ==================== Rich Text Editor ==================== */

.rich-text-editor {
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  overflow: hidden;
  background: rgba(0, 0, 0, 0.3);
}

.rte-toolbar {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.35rem 0.5rem;
  background: rgba(0, 0, 0, 0.4);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  flex-wrap: nowrap;
}

.rte-btn {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: white;
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.85rem;
  min-width: 28px;
  transition: all 0.2s;
}

.rte-btn:hover {
  background: rgba(255, 255, 255, 0.2);
}

.rte-btn:active {
  background: rgba(25, 118, 210, 0.4);
}

.rte-select {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: white;
  padding: 0.25rem 0.3rem;
  border-radius: 4px;
  font-size: 0.8rem;
  cursor: pointer;
}

.rte-select option {
  background: #333;
  color: white;
}

.rte-btn.rte-suit {
  font-size: 1.1rem;
  font-weight: bold;
  min-width: 26px;
  padding: 0.15rem 0.35rem;
}

.rte-separator {
  width: 1px;
  height: 20px;
  background: rgba(255, 255, 255, 0.2);
  margin: 0 0.25rem;
}

.additional-text-row {
  display: flex;
  gap: 0.4rem;
  align-items: center;
}

.additional-text-row input {
  flex: 1;
}

.suit-buttons-mini {
  display: flex;
  gap: 0.15rem;
}

.suit-buttons-mini button {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 4px;
  cursor: pointer;
  font-size: 1.1rem;
  font-weight: bold;
  padding: 0.2rem 0.4rem;
  line-height: 1;
  transition: background 0.2s;
}

.suit-buttons-mini button:hover {
  background: rgba(255, 255, 255, 0.2);
}

.rte-content {
  min-height: 120px;
  max-height: 300px;
  overflow-y: auto;
  padding: 1rem;
  color: white;
  line-height: 1.6;
  outline: none;
}

.rte-content.rte-compact {
  min-height: 40px;
  max-height: 100px;
}

.rte-content:empty:before {
  content: attr(data-placeholder);
  color: rgba(255, 255, 255, 0.4);
  pointer-events: none;
}

.rte-content:focus {
  background: rgba(0, 0, 0, 0.4);
}

/* Override black spade color to white in editor (dark background) */
.rte-content span[style*="color:#000000"] {
  color: #ffffff !important;
}


/* Styles for content within editor */
.rte-content strong,
.rte-content b {
  font-weight: bold;
}

.rte-content u {
  text-decoration: underline;
}

/* ==================== HTML Content Display (Quiz Page) ==================== */

.explanation-html {
  color: var(--text-dark);
  font-size: 1rem;
  line-height: 1.6;
}

.explanation-html strong,
.explanation-html b {
  font-weight: bold;
}

.explanation-html u {
  text-decoration: underline;
}

.explanation-html em,
.explanation-html i {
  font-style: italic;
}

.explanation-html p {
  margin-bottom: 0.5rem;
}

.explanation-html div[style*="margin-left"],
.explanation-html p[style*="margin-left"] {
  padding-left: 0.5rem;
  border-left: 2px solid rgba(255, 255, 255, 0.15);
}

/* ==================== Auth Page ==================== */

.auth-container {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  padding: 2rem;
}

.auth-card {
  background: var(--card-background);
  border-radius: 16px;
  padding: 2rem;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

.auth-header {
  text-align: center;
  margin-bottom: 2rem;
}

.auth-icon {
  margin-bottom: 1rem;
}

.auth-header h2 {
  color: var(--text-dark);
  font-size: 1.8rem;
  margin-bottom: 0.5rem;
}

.auth-subtitle {
  color: #666;
  font-size: 0.95rem;
}

.auth-error {
  background: #ffebee;
  color: var(--error-red);
  padding: 0.75rem 1rem;
  border-radius: 8px;
  margin-bottom: 1rem;
  font-size: 0.9rem;
  text-align: center;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.auth-field {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.auth-field label {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-dark);
}

.auth-field input {
  padding: 0.75rem 1rem;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  font-size: 1rem;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.auth-field input:focus {
  outline: none;
  border-color: var(--primary-green);
  box-shadow: 0 0 0 3px rgba(46, 125, 50, 0.1);
}

.auth-submit {
  margin-top: 0.5rem;
  padding: 0.875rem;
  font-size: 1rem;
}

.auth-divider {
  display: flex;
  align-items: center;
  margin: 1.5rem 0;
  gap: 1rem;
}

.auth-divider::before,
.auth-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border-color);
}

.auth-divider span {
  color: #999;
  font-size: 0.85rem;
}

.auth-google {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 0.75rem;
}

.auth-switch {
  text-align: center;
  margin-top: 1.5rem;
  color: var(--text-dark);
  font-size: 0.9rem;
}

.auth-link {
  background: none;
  border: none;
  color: var(--secondary-blue);
  cursor: pointer;
  font-size: inherit;
  text-decoration: underline;
}

.auth-link:hover {
  color: var(--primary-green);
}

/* ==================== Header User Info ==================== */

.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.btn-fullscreen {
  background: rgba(255, 255, 255, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.3);
  color: white;
  width: 36px;
  height: 36px;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  transition: all 0.2s ease;
}

.btn-fullscreen:hover {
  background: rgba(255, 255, 255, 0.25);
  border-color: rgba(255, 255, 255, 0.5);
}

.btn-fullscreen:active {
  transform: scale(0.95);
}

.header-user {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.header-email {
  font-size: 0.9rem;
  opacity: 0.9;
}

.header-admin-badge {
  background: var(--warning-yellow);
  color: var(--text-dark);
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 600;
}

/* Header Score Display (during quiz) */
.header-score {
  display: flex;
  gap: 1.5rem;
  background: var(--section-bg);
  padding: 0.4rem 1rem;
  border-radius: 8px;
}

.header-score-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.1rem;
}

.header-score-label {
  font-size: 0.7rem;
  opacity: 0.8;
  text-transform: uppercase;
}

.header-score-value {
  font-size: 1.1rem;
  font-weight: bold;
}

.header-score-value.correct {
  color: var(--success-green);
}

.header-score-value.incorrect {
  color: var(--error-red);
}

.header-score-value.percentage {
  color: var(--warning-yellow);
}

@media (max-width: 768px) {
  .header-score {
    gap: 0.75rem;
    padding: 0.3rem 0.5rem;
  }

  .header-score-label {
    font-size: 0.6rem;
  }

  .header-score-value {
    font-size: 0.9rem;
  }
}

.btn-small {
  padding: 0.4rem 0.75rem;
  font-size: 0.85rem;
}

/* ==================== File Upload ==================== */

.file-upload-section {
  margin-top: 1.5rem;
  padding: 1.5rem;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 8px;
  border: 1px dashed var(--border-color);
}

.file-upload-section h3 {
  margin-bottom: 1rem;
  font-size: 1.1rem;
}

.file-upload-input {
  display: block;
  width: 100%;
  padding: 1rem;
  background: white;
  border: 2px dashed var(--border-color);
  border-radius: 8px;
  cursor: pointer;
  text-align: center;
  transition: border-color 0.2s;
}

.file-upload-input:hover {
  border-color: var(--primary-green);
}

.file-upload-select {
  margin-top: 1rem;
  display: flex;
  gap: 1rem;
}

.file-upload-select select {
  flex: 1;
  padding: 0.5rem;
  border-radius: 4px;
  border: 1px solid var(--border-color);
}

.upload-progress {
  margin-top: 1rem;
  padding: 1rem;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 8px;
}

.upload-result {
  margin-top: 1rem;
  padding: 1rem;
  border-radius: 8px;
}

.upload-result.success {
  background: rgba(76, 175, 80, 0.2);
  border: 1px solid var(--success-green);
}

.upload-result.error {
  background: rgba(244, 67, 54, 0.2);
  border: 1px solid var(--error-red);
}

/* ==================== Account Menu ==================== */

.account-menu {
  position: relative;
}

.account-menu-trigger {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  padding: 0.4rem 0.75rem;
  border-radius: 8px;
  cursor: pointer;
  color: white;
  transition: all 0.2s;
}

.account-menu-trigger:hover {
  background: rgba(255, 255, 255, 0.2);
}

.account-avatar {
  width: 28px;
  height: 28px;
  background: var(--secondary-blue);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 0.9rem;
}

.account-email {
  font-size: 0.85rem;
  max-width: 150px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account-chevron {
  font-size: 0.7rem;
  opacity: 0.7;
}

.account-menu-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 99;
}

.account-menu-dropdown {
  position: absolute;
  top: calc(100% + 0.5rem);
  right: 0;
  background: var(--dropdown-bg);
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
  min-width: 280px;
  z-index: 100;
  overflow: hidden;
}

.account-menu-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1.25rem;
  background: linear-gradient(135deg, var(--primary-green) 0%, var(--primary-green-hover) 100%);
  color: white;
}

.account-menu-avatar {
  width: 48px;
  height: 48px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 1.4rem;
}

.account-menu-info {
  flex: 1;
  min-width: 0;
}

.account-menu-email {
  font-weight: 600;
  font-size: 0.95rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.account-menu-role {
  font-size: 0.8rem;
  opacity: 0.9;
  margin-top: 0.2rem;
}

.account-menu-divider {
  height: 1px;
  background: var(--dropdown-divider);
}

.account-menu-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
  padding: 0.875rem 1.25rem;
  background: var(--dropdown-bg);
  border: none;
  cursor: pointer;
  font-size: 0.95rem;
  color: var(--dropdown-text);
  transition: background 0.2s;
  text-align: left;
}

.account-menu-item:hover {
  background: var(--dropdown-hover);
}

.account-menu-item.account-menu-logout {
  color: var(--error-red);
}

.account-menu-item.account-menu-logout:hover {
  background: #ffebee;
}

.account-menu-item.account-menu-delete {
  color: #e74c3c;
  font-size: 0.85rem;
}

.account-menu-item.account-menu-delete:hover {
  background: #ffebee;
}

.delete-account-warning {
  background: rgba(231, 76, 60, 0.1);
  border: 1px solid rgba(231, 76, 60, 0.3);
  border-radius: 8px;
  padding: 1rem;
  margin-bottom: 1rem;
  font-size: 0.9rem;
  line-height: 1.5;
}

.delete-account-warning p {
  margin: 0.3rem 0;
}

.delete-account-warning ul {
  margin: 0.5rem 0;
  padding-left: 1.5rem;
}

.delete-account-warning li {
  margin: 0.2rem 0;
}

.account-menu-icon {
  font-size: 1.1rem;
  width: 24px;
  text-align: center;
}

/* Theme Selector in Account Menu */
.theme-selector-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1.25rem;
  background: var(--dropdown-bg);
}

.theme-selector-label {
  font-size: 0.95rem;
  color: var(--dropdown-text);
  white-space: nowrap;
}

.theme-selector-swatches {
  display: flex;
  gap: 0.5rem;
}

.theme-swatch {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
}

.theme-swatch:hover {
  transform: scale(1.15);
}

.theme-swatch.active {
  border-color: var(--dropdown-text);
  box-shadow: 0 0 0 2px var(--dropdown-bg), 0 0 0 4px var(--dropdown-text);
}

.theme-swatch-classique {
  background: linear-gradient(135deg, #0d1f14 50%, #1a472a 50%);
}

.theme-swatch-bleu-nuit {
  background: linear-gradient(135deg, #0f1a2e 50%, #c9a84c 50%);
}

.theme-swatch-tapis-vert {
  background: linear-gradient(135deg, #1a3320 50%, #f5f0e0 50%);
}

/* Account Modal (Password Change) */
.account-modal {
  max-width: 400px;
}

.account-modal h2 {
  color: var(--primary-green);
  margin-bottom: 1.5rem;
  font-size: 1.4rem;
}

.auth-success {
  background: #e8f5e9;
  color: var(--success-green);
  padding: 0.75rem 1rem;
  border-radius: 8px;
  margin-bottom: 1rem;
  font-size: 0.9rem;
  text-align: center;
}

@media (max-width: 600px) {
  .account-email {
    display: none;
  }

  .account-menu-dropdown {
    position: fixed;
    top: auto;
    bottom: 0;
    left: 0;
    right: 0;
    border-radius: 12px 12px 0 0;
    min-width: 100%;
  }
}

/* ==================== MESSAGING SYSTEM ==================== */

/* Admin Controls Bar */
.header-admin-controls {
  display: flex;
  gap: 0.5rem;
}

.btn-admin {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: white;
  padding: 0.5rem 1rem;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  transition: all 0.2s;
}

.btn-admin:hover {
  background: rgba(255, 255, 255, 0.2);
}

.btn-admin .badge {
  background: var(--error-red);
  color: white;
  padding: 0.1rem 0.4rem;
  border-radius: 10px;
  font-size: 0.75rem;
  font-weight: bold;
}

/* Broadcast Banner */
.broadcast-banner {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: linear-gradient(90deg, var(--secondary-blue) 0%, #1565c0 100%);
  color: white;
  padding: 0.75rem 1rem;
  border-radius: 8px;
  margin-bottom: 1rem;
}

.broadcast-icon {
  font-size: 1.2rem;
}

.broadcast-message {
  flex: 1;
  line-height: 1.4;
}

.broadcast-dismiss {
  background: none;
  border: none;
  color: white;
  font-size: 1.5rem;
  cursor: pointer;
  opacity: 0.7;
  padding: 0;
  line-height: 1;
}

.broadcast-dismiss:hover {
  opacity: 1;
}

/* Contact Admin Modal */
.contact-modal {
  max-width: 500px;
}

.contact-form textarea {
  width: 100%;
  resize: vertical;
  min-height: 100px;
}

/* Admin Messages Modal */
.admin-messages-modal {
  max-width: 900px;
  width: 90vw;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
}

.admin-messages-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.admin-messages-header h2 {
  flex: 1;
  margin: 0;
}

.unread-badge {
  background: var(--error-red);
  color: white;
  padding: 0.25rem 0.75rem;
  border-radius: 12px;
  font-size: 0.85rem;
}

.modal-close {
  background: none;
  border: none;
  color: white;
  font-size: 2rem;
  cursor: pointer;
  opacity: 0.7;
  padding: 0;
  line-height: 1;
}

.modal-close:hover {
  opacity: 1;
}

.admin-messages-layout {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 1rem;
  flex: 1;
  overflow: hidden;
  margin-top: 1rem;
}

.messages-list {
  overflow-y: auto;
  max-height: 50vh;
  border-right: 1px solid rgba(255, 255, 255, 0.1);
  padding-right: 1rem;
}

.message-item {
  padding: 0.75rem;
  border-radius: 6px;
  cursor: pointer;
  margin-bottom: 0.5rem;
  background: rgba(255, 255, 255, 0.05);
  transition: background 0.2s;
}

.message-item:hover {
  background: rgba(255, 255, 255, 0.1);
}

.message-item.selected {
  background: rgba(255, 255, 255, 0.15);
  border-left: 3px solid var(--secondary-blue);
}

.message-item.unread {
  border-left: 3px solid var(--warning-yellow);
}

.message-item.read {
  border-left: 3px solid var(--success-green);
}

.message-item.unread .message-email {
  font-weight: bold;
}

.message-item-header {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  margin-bottom: 0.25rem;
}

.message-item-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
}

.btn-mark-read {
  background: #6b7280;
  color: white;
  border: none;
  border-radius: 4px;
  padding: 0.2rem 0.5rem;
  font-size: 0.75rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
  flex-shrink: 0;
}

.btn-mark-read:hover:not(.is-read) {
  background: #4b5563;
  transform: scale(1.05);
}

.btn-mark-read.is-read {
  background: var(--success-green);
  cursor: default;
}

.btn-mark-read.is-read:hover {
  transform: none;
}

.message-email {
  font-size: 0.9rem;
}

.message-date {
  font-size: 0.75rem;
  opacity: 0.7;
}

.message-subject {
  font-size: 0.85rem;
  opacity: 0.9;
  margin-bottom: 0.25rem;
}

.message-preview {
  font-size: 0.8rem;
  opacity: 0.6;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.message-detail {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.message-detail-header {
  background: rgba(255, 255, 255, 0.05);
  padding: 1rem;
  border-radius: 6px;
}

.message-detail-header > div {
  margin-bottom: 0.5rem;
}

.message-detail-header > div:last-child {
  margin-bottom: 0;
}

.message-detail-body {
  flex: 1;
  background: rgba(255, 255, 255, 0.05);
  padding: 1rem;
  border-radius: 6px;
  white-space: pre-wrap;
  line-height: 1.6;
}

.message-detail-actions {
  display: flex;
  gap: 0.5rem;
}

/* Broadcast Editor Modal */
.broadcast-modal {
  max-width: 500px;
}

.broadcast-form textarea {
  width: 100%;
  resize: vertical;
  min-height: 100px;
}

.checkbox-field {
  display: flex;
  align-items: center;
  margin-top: 1rem;
}

.checkbox-field label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
}

.checkbox-field input[type="checkbox"] {
  width: 18px;
  height: 18px;
  cursor: pointer;
}

/* Empty and Loading States */
.empty-state,
.loading-state {
  text-align: center;
  padding: 2rem;
  opacity: 0.7;
}

/* Responsive */
@media (max-width: 768px) {
  .admin-messages-layout {
    grid-template-columns: 1fr;
  }

  .messages-list {
    border-right: none;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding-right: 0;
    padding-bottom: 1rem;
    max-height: 30vh;
  }

  .header-admin-controls {
    display: none;
  }
}

/* ==================== Reimport Feature ==================== */

.btn-reimport {
  background: #c62828;
  color: white;
  border: none;
  padding: 0.6rem 1.2rem;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-reimport:hover {
  background: #b71c1c;
}

.btn-reimport:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.reimport-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.reimport-dialog {
  background: var(--background-felt);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 16px;
  padding: 2rem;
  max-width: 600px;
  width: 90vw;
  max-height: 80vh;
  overflow-y: auto;
  color: white;
}

.reimport-dialog h2 {
  margin: 0 0 1rem 0;
  font-size: 1.4rem;
}

.reimport-dialog h3 {
  margin: 0.75rem 0 0.5rem 0;
  font-size: 1.1rem;
}

.reimport-warning {
  background: rgba(198, 40, 40, 0.3);
  border: 1px solid rgba(198, 40, 40, 0.6);
  border-radius: 8px;
  padding: 1rem;
  margin-bottom: 1.5rem;
  line-height: 1.5;
  font-size: 0.95rem;
}

.reimport-summary {
  margin-bottom: 1.5rem;
}

.reimport-theme-item {
  margin-bottom: 0.5rem;
  padding: 0.5rem;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 6px;
}

.reimport-theme-item ul {
  margin: 0.3rem 0 0 1.5rem;
  padding: 0;
  font-size: 0.85rem;
  opacity: 0.8;
}

.reimport-theme-item li {
  margin: 0.15rem 0;
}

.reimport-unmapped {
  margin-top: 0.75rem;
  color: #ff9800;
  font-size: 0.9rem;
}

.reimport-actions {
  display: flex;
  gap: 1rem;
  justify-content: flex-end;
  margin-top: 1.5rem;
}

.btn-cancel {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.3);
  color: white;
  padding: 0.6rem 1.2rem;
  border-radius: 8px;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-cancel:hover {
  background: rgba(255, 255, 255, 0.2);
}

.btn-reimport-confirm {
  background: #c62828;
  color: white;
  border: none;
  padding: 0.6rem 1.5rem;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-reimport-confirm:hover {
  background: #b71c1c;
}

.btn-reimport-confirm:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.reimport-progress-bar {
  width: 100%;
  height: 12px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 6px;
  overflow: hidden;
  margin: 1rem 0;
}

.reimport-progress-fill {
  height: 100%;
  background: var(--success-green);
  border-radius: 6px;
  transition: width 0.3s ease;
}

.reimport-progress-indeterminate {
  width: 30% !important;
  animation: reimport-indeterminate 1.5s ease-in-out infinite;
}

@keyframes reimport-indeterminate {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(400%); }
}

.reimport-result-count {
  font-size: 1.1rem;
  margin: 0.5rem 0;
}

.reimport-errors-list {
  margin-top: 1rem;
  background: rgba(244, 67, 54, 0.15);
  border: 1px solid rgba(244, 67, 54, 0.3);
  border-radius: 8px;
  padding: 1rem;
  max-height: 200px;
  overflow-y: auto;
}

.reimport-errors-list h3 {
  color: var(--error-red);
  margin: 0 0 0.5rem 0;
}

.reimport-errors-list ul {
  margin: 0;
  padding-left: 1.5rem;
  font-size: 0.85rem;
  opacity: 0.9;
}

.reimport-errors-list li {
  margin: 0.25rem 0;
}
