/* ============ RESET & BASE ============ */
* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0f1218;
  --bg-soft: #181c25;
  --bg-card: #1f2430;
  --bg-elev: #2a3142;
  --border: #2d3548;
  --text: #e6e9ef;
  --text-dim: #8b93a7;
  --primary: #6366f1;
  --primary-hover: #7c7ff5;
  --primary-soft: rgba(99,102,241,0.15);
  --success: #10b981;
  --danger: #ef4444;
  --warning: #f59e0b;
  --shadow: 0 10px 30px rgba(0,0,0,0.4);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  font-size: 14px;
  line-height: 1.5;
}

.hidden { display: none !important; }

button { cursor: pointer; font-family: inherit; border: none; background: none; color: inherit; }
input, select, textarea {
  font-family: inherit;
  font-size: 14px;
  background: var(--bg-soft);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  width: 100%;
  transition: border-color 0.15s, box-shadow 0.15s;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}

/* ============ BOUTONS ============ */
.btn-primary {
  background: var(--primary);
  color: white;
  padding: 10px 18px;
  border-radius: 8px;
  font-weight: 600;
  transition: background 0.15s, transform 0.05s;
}
.btn-primary:hover { background: var(--primary-hover); }
.btn-primary:active { transform: translateY(1px); }

.btn-ghost {
  padding: 8px 14px;
  border-radius: 8px;
  color: var(--text-dim);
  border: 1px solid var(--border);
  background: var(--bg-soft);
  font-weight: 500;
  transition: all 0.15s;
}
.btn-ghost:hover { color: var(--text); border-color: var(--primary); }

.btn-icon {
  padding: 6px 10px;
  border-radius: 6px;
  color: var(--text-dim);
  transition: all 0.15s;
}
.btn-icon:hover { background: var(--bg-elev); color: var(--text); }
.btn-icon.danger:hover { color: var(--danger); }

.btn-close {
  width: 32px; height: 32px;
  border-radius: 8px;
  color: var(--text-dim);
  font-size: 18px;
}
.btn-close:hover { background: var(--bg-elev); color: var(--text); }

/* ============ AUTH ============ */
.auth-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: radial-gradient(ellipse at top, rgba(99,102,241,0.15), transparent 60%);
}

.auth-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 40px;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow);
}

.auth-card h1 {
  font-size: 28px;
  margin-bottom: 8px;
  text-align: center;
}

.subtitle {
  color: var(--text-dim);
  text-align: center;
  margin-bottom: 28px;
  font-size: 13px;
}

.tabs-auth {
  display: flex;
  gap: 4px;
  background: var(--bg-soft);
  padding: 4px;
  border-radius: 10px;
  margin-bottom: 24px;
}

.tab-auth {
  flex: 1;
  padding: 8px 12px;
  border-radius: 7px;
  color: var(--text-dim);
  font-weight: 500;
  font-size: 13px;
  transition: all 0.15s;
}
.tab-auth.active {
  background: var(--bg-card);
  color: var(--text);
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

#auth-form label {
  display: block;
  margin-bottom: 14px;
  font-size: 13px;
  color: var(--text-dim);
  font-weight: 500;
}
#auth-form label input {
  margin-top: 6px;
}
#auth-submit { width: 100%; margin-top: 10px; padding: 12px; }

.error-msg {
  color: var(--danger);
  font-size: 13px;
  min-height: 18px;
  margin-bottom: 8px;
}

/* ============ APP ============ */
.app { min-height: 100vh; display: flex; flex-direction: column; }

.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 24px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
}
.app-header h1 { font-size: 18px; font-weight: 700; }
.header-left, .header-right { display: flex; align-items: center; gap: 12px; }

.user-email {
  color: var(--text-dim);
  font-size: 13px;
  padding: 6px 12px;
  background: var(--bg-soft);
  border-radius: 6px;
}

/* Onglets de catégories */
.tabs {
  display: flex;
  gap: 2px;
  padding: 0 24px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
}

.tab {
  padding: 14px 18px;
  color: var(--text-dim);
  font-weight: 500;
  font-size: 14px;
  white-space: nowrap;
  border-bottom: 2px solid transparent;
  transition: all 0.15s;
  margin-bottom: -1px;
}
.tab:hover { color: var(--text); }
.tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

.content {
  flex: 1;
  padding: 24px;
  max-width: 1400px;
  margin: 0 auto;
  width: 100%;
}

/* ============ TOOLBAR ============ */
.toolbar {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
  align-items: center;
}

.search-box { flex: 1; min-width: 220px; }
.search-box input { padding: 10px 14px; }

.filters {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.filters select, .filters input {
  width: auto;
  min-width: 130px;
  padding: 8px 12px;
  font-size: 13px;
}

.stats {
  color: var(--text-dim);
  font-size: 13px;
  margin-bottom: 12px;
  padding: 0 4px;
}

/* ============ TABLE ============ */
.table-wrapper {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

thead {
  background: var(--bg-soft);
}

th {
  padding: 12px 16px;
  text-align: left;
  font-weight: 600;
  color: var(--text-dim);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
  border-bottom: 1px solid var(--border);
}
th:hover { color: var(--text); }
th.sortable::after {
  content: ' ⇅';
  opacity: 0.3;
  font-size: 11px;
}
th.sort-asc::after { content: ' ↑'; opacity: 1; color: var(--primary); }
th.sort-desc::after { content: ' ↓'; opacity: 1; color: var(--primary); }

td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

tbody tr { transition: background 0.1s; }
tbody tr:hover { background: var(--bg-soft); }
tbody tr:last-child td { border-bottom: none; }

.title-cell {
  font-weight: 600;
  color: var(--text);
}

.rating-pill {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 12px;
  font-weight: 600;
  font-size: 12px;
  background: var(--primary-soft);
  color: var(--primary);
}
.rating-pill.high { background: rgba(16,185,129,0.15); color: var(--success); }
.rating-pill.mid { background: rgba(245,158,11,0.15); color: var(--warning); }
.rating-pill.low { background: rgba(239,68,68,0.15); color: var(--danger); }

.progress-pill {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 12px;
  font-weight: 600;
  font-size: 12px;
  background: var(--bg-elev);
  color: var(--text-dim);
  white-space: nowrap;
}

.actions-cell {
  white-space: nowrap;
  /*text-align: right;*/
}

.empty-state {
  padding: 60px 24px;
  text-align: center;
  color: var(--text-dim);
}
.empty-state p { margin-bottom: 8px; }

/* ============ MODAL ============ */
.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(4px);
}

.modal-card {
  position: relative;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 14px;
  width: 100%;
  max-width: 640px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
}
.modal-header h2 { font-size: 18px; }

#item-form {
  padding: 24px;
  overflow-y: auto;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
}
.form-grid .full { grid-column: 1 / -1; }

.form-grid label {
  display: block;
  font-size: 12px;
  color: var(--text-dim);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}
.form-grid label input,
.form-grid label select,
.form-grid label textarea {
  margin-top: 4px;
}
.form-grid textarea { resize: vertical; min-height: 70px; }

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding-top: 20px;
  margin-top: 20px;
  border-top: 1px solid var(--border);
}

/* ============ TOAST ============ */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  padding: 12px 18px;
  border-radius: 10px;
  box-shadow: var(--shadow);
  z-index: 200;
  font-weight: 500;
  animation: slideUp 0.2s ease;
}
.toast.success { border-color: var(--success); }
.toast.error { border-color: var(--danger); }

@keyframes slideUp {
  from { transform: translateY(20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

/* ============ RESPONSIVE ============ */
/* ============ LAYOUT PRINCIPAL (sidebar + contenu) ============ */
.app {
  display: flex;
  min-height: 100vh;
}

/* ============ SIDEBAR ============ */
.sidebar {
  width: 60px;
  background: var(--bg-card);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 12px 0;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 50;
}

.sidebar-logo {
  font-size: 22px;
  margin-bottom: 20px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
  width: 100%;
  text-align: center;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
}

.sidebar-bottom {
  padding-top: 12px;
  border-top: 1px solid var(--border);
  width: 100%;
  display: flex;
  justify-content: center;
}

.nav-item {
  width: 44px; height: 44px;
  border-radius: 10px;
  font-size: 20px;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-dim);
  transition: all 0.15s;
  position: relative;
}
.nav-item:hover { background: var(--bg-elev); color: var(--text); }
.nav-item.active { background: var(--primary-soft); color: var(--primary); }

/* ============ CONTENU PRINCIPAL ============ */
.main-content {
  margin-left: 60px;
  flex: 1;
  min-height: 100vh;
  overflow-x: hidden;
}

.section { display: none; }
.section.active { display: block; }

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 15px 28px;
}
.section-header h1 { font-size: 22px; }
.header-actions { display: flex; gap: 10px; }

/* ============ HOME ============ */
.home-header {
  padding: 36px 28px 24px;
}
.home-header h1 { font-size: 28px; font-weight: 700; }
.home-subtitle { color: var(--text-dim); margin-top: 6px; }

.home-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
  padding: 0 28px 28px;
}

.home-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 24px;
  display: flex;
  gap: 18px;
  align-items: flex-start;
  cursor: pointer;
  transition: all 0.15s;
}
.home-card:hover {
  border-color: var(--primary);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(99,102,241,0.15);
}
.card-icon { font-size: 36px; line-height: 1; }
.card-info h2 { font-size: 16px; font-weight: 700; margin-bottom: 4px; }
.card-info p { font-size: 13px; color: var(--text-dim); margin-bottom: 8px; }
.card-stat {
  font-size: 12px;
  font-weight: 600;
  color: var(--primary);
  background: var(--primary-soft);
  padding: 3px 10px;
  border-radius: 20px;
}

.home-section {
  padding: 0 28px 24px;
}
.home-section h3 {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 12px;
}

.home-preview-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.home-preview-item {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  transition: border-color 0.1s;
}
.home-preview-item:hover { border-color: var(--primary); }
.home-preview-item.done-item { opacity: 0.5; text-decoration: line-through; }
.home-preview-empty {
  color: var(--text-dim);
  font-size: 13px;
  font-style: italic;
  padding: 8px 0;
}

/* ============ BIBLIOTHÈQUE ============ */
.tabs {
  display: flex;
  gap: 2px;
  /*padding: 16px 28px 0;*/
  overflow-x: auto;
  scrollbar-width: none;
}

.content { padding: 20px 28px; }

/* ============ TODOS ============ */
.todos-tabs {
  display: flex;
  gap: 4px;
  padding: 16px 28px 0;
}

.todo-tab {
  padding: 10px 18px;
  border-radius: 8px;
  color: var(--text-dim);
  font-weight: 500;
  font-size: 14px;
  border: 1px solid var(--border);
  background: var(--bg-soft);
  transition: all 0.15s;
}
.todo-tab.active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

.todos-container {
  padding: 20px 28px;
  max-width: 700px;
}

.todo-input-row {
  display: flex;
  gap: 10px;
  margin-bottom: 14px;
}
.todo-input-row input { flex: 1; }

.todo-filters {
  display: flex;
  gap: 6px;
  margin-bottom: 16px;
}

.todo-filter {
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-dim);
  border: 1px solid var(--border);
  background: var(--bg-soft);
  transition: all 0.15s;
}
.todo-filter.active {
  background: var(--primary-soft);
  color: var(--primary);
  border-color: var(--primary);
}

.todo-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.todo-item {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  transition: all 0.15s;
  animation: fadeIn 0.2s ease;
}
.todo-item:hover { border-color: var(--border); background: var(--bg-soft); }
.todo-item.done .todo-text { text-decoration: line-through; color: var(--text-dim); }

.todo-checkbox {
  width: 20px; height: 20px;
  border-radius: 6px;
  border: 2px solid var(--border);
  cursor: pointer;
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.15s;
  background: transparent;
  font-size: 12px;
}
.todo-checkbox.checked {
  background: var(--success);
  border-color: var(--success);
  color: white;
}

.todo-text {
  flex: 1;
  font-size: 14px;
  line-height: 1.4;
  cursor: text;
  outline: none;
  border: none;
  background: transparent;
  color: var(--text);
  font-family: inherit;
}
.todo-text:focus { color: var(--text); }

.todo-delete {
  opacity: 0;
  padding: 4px 8px;
  border-radius: 6px;
  color: var(--text-dim);
  font-size: 16px;
  transition: all 0.15s;
}
.todo-item:hover .todo-delete { opacity: 1; }
.todo-delete:hover { color: var(--danger); background: rgba(239,68,68,0.1); }

.todo-footer {
  margin-top: 14px;
  font-size: 13px;
  color: var(--text-dim);
}

/* ============ NOTES & AVIS ============ */
.notes-layout {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

.notes-sidebar {
  width: 280px;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  background: var(--bg-card);
  flex-shrink: 0;
}

.notes-sidebar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 16px 12px;
  border-bottom: 1px solid var(--border);
}
.notes-sidebar-header h2 { font-size: 16px; }

#note-search {
  margin: 10px 12px;
  width: calc(100% - 24px);
  font-size: 13px;
}

.notes-list {
  list-style: none;
  overflow-y: auto;
  flex: 1;
}

.note-list-item {
  padding: 12px 16px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  transition: background 0.1s;
}
.note-list-item:hover { background: var(--bg-soft); }
.note-list-item.active { background: var(--primary-soft); border-left: 3px solid var(--primary); }

.note-list-title {
  font-weight: 600;
  font-size: 14px;
  margin-bottom: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.note-list-meta {
  font-size: 11px;
  color: var(--text-dim);
  display: flex;
  gap: 8px;
  align-items: center;
}
.note-list-link {
  background: var(--primary-soft);
  color: var(--primary);
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 10px;
}

.notes-editor {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.editor-empty {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-dim);
  font-size: 15px;
}

#editor-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.editor-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-card);
  flex-wrap: wrap;
}

.note-title-input {
  flex: 1;
  font-size: 18px;
  font-weight: 700;
  background: transparent;
  border: none;
  border-radius: 0;
  color: var(--text);
  min-width: 200px;
}
.note-title-input:focus { box-shadow: none; border-color: transparent; }

.editor-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-shrink: 0;
}

.linked-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: 20px;
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.danger-btn { color: var(--danger) !important; }
.danger-btn:hover { background: rgba(239,68,68,0.1) !important; }

#editor-panels {
  flex: 1;
  display: flex;
  overflow: hidden;
}

.note-body-input {
  flex: 1;
  resize: none;
  border: none;
  border-radius: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'JetBrains Mono', 'Fira Code', 'Consolas', monospace;
  font-size: 14px;
  line-height: 1.7;
  padding: 24px 28px;
  overflow-y: auto;
}
.note-body-input:focus { box-shadow: none; border: none; }

.note-preview {
  flex: 1;
  padding: 24px 28px;
  overflow-y: auto;
  background: var(--bg);
  line-height: 1.7;
  font-size: 15px;
}

/* Styles Markdown rendu */
.note-preview h1 { font-size: 24px; font-weight: 700; margin: 0 0 16px; border-bottom: 1px solid var(--border); padding-bottom: 8px; }
.note-preview h2 { font-size: 20px; font-weight: 700; margin: 24px 0 12px; }
.note-preview h3 { font-size: 16px; font-weight: 600; margin: 20px 0 8px; }
.note-preview p { margin: 0 0 12px; }
.note-preview ul, .note-preview ol { padding-left: 24px; margin: 0 0 12px; }
.note-preview li { margin-bottom: 4px; }
.note-preview blockquote { border-left: 3px solid var(--primary); padding-left: 16px; color: var(--text-dim); margin: 0 0 12px; }
.note-preview code { background: var(--bg-elev); padding: 2px 6px; border-radius: 4px; font-family: monospace; font-size: 13px; }
.note-preview pre { background: var(--bg-elev); padding: 16px; border-radius: 8px; overflow-x: auto; margin: 0 0 12px; }
.note-preview pre code { background: none; padding: 0; }
.note-preview strong { font-weight: 700; }
.note-preview em { font-style: italic; }
.note-preview hr { border: none; border-top: 1px solid var(--border); margin: 20px 0; }

.editor-meta {
  padding: 8px 20px;
  font-size: 12px;
  color: var(--text-dim);
  border-top: 1px solid var(--border);
  background: var(--bg-card);
}

/* Résultats de la recherche lien */
.link-results {
  list-style: none;
  max-height: 300px;
  overflow-y: auto;
  margin-top: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

.link-result-item {
  padding: 10px 14px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  transition: background 0.1s;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.link-result-item:last-child { border-bottom: none; }
.link-result-item:hover { background: var(--bg-soft); }
.link-result-title { font-weight: 600; font-size: 14px; }
.link-result-cat { font-size: 11px; color: var(--text-dim); text-transform: uppercase; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ============================================================
   RESPONSIVE MOBILE (≤ 768px)
   Sidebar → barre de navigation en bas (style app mobile)
   Notes → plein écran avec retour
   Tout le reste → adapté téléphone
   ============================================================ */
@media (max-width: 768px) {

  /* --- Sidebar → bottom nav bar --- */
  .sidebar {
    width: 100%;
    height: 56px;
    flex-direction: row;
    position: fixed;
    top: auto;
    bottom: 0; left: 0; right: 0;
    border-right: none;
    border-top: 1px solid var(--border);
    padding: 0 8px;
    justify-content: space-around;
    z-index: 100;
    background: var(--bg-card);
  }

  .sidebar-logo { display: none; }

  .sidebar-nav {
    flex-direction: row;
    flex: 1;
    gap: 0;
    justify-content: space-around;
  }

  .sidebar-bottom {
    border-top: none;
    padding: 0;
  }

  .nav-item {
    width: 48px; height: 48px;
    border-radius: 8px;
    font-size: 22px;
  }

  /* --- Contenu principal → padding bas pour la nav bar --- */
  .main-content {
    margin-left: 0;
    padding-bottom: 64px;
  }

  /* --- Home --- */
  .home-header { padding: 20px 16px 16px; }
  .home-header h1 { font-size: 22px; }
  .home-cards { grid-template-columns: 1fr; padding: 0 16px 16px; gap: 12px; }
  .home-card { padding: 16px; }
  .card-icon { font-size: 28px; }
  .home-section { padding: 0 16px 16px; }

  /* --- Section header --- */
  .section-header { padding: 16px 16px; flex-wrap: wrap; gap: 8px; }
  .section-header h1 { font-size: 18px; }
  .header-actions { gap: 6px; }
  .header-actions .btn-ghost { padding: 6px 10px; font-size: 12px; }

  /* --- Bibliothèque --- */
  .tabs {
    padding: 5px 16px;
    gap: 4px;
    overflow-x: auto;
    scrollbar-width: none;
  }
  .tabs::-webkit-scrollbar { display: none; }
  .tab { padding: 8px 12px; font-size: 12px; white-space: nowrap; }

  .content { padding: 12px 16px; }

  .toolbar { flex-direction: column; gap: 8px; }
  .search-box { width: 100%; }
  .filters { flex-wrap: wrap; gap: 6px; }
  .filters select { font-size: 12px; padding: 6px 8px; min-width: 100px; }

  .table-wrapper { border-radius: 8px; }
  table { font-size: 12px; }
  th, td { padding: 8px 10px; }
  /* Cacher certaines colonnes moins importantes sur mobile */
  /*th:nth-child(n+5), td:nth-child(n+5) { display: none; }*/
  /* Mais toujours montrer la dernière colonne (actions) */
  /*th:last-child, td:last-child { display: table-cell; }*/

  /* Mobile : on cache tout sauf titre, genre, studio/saison, note, actions */
  th, td { display: none; }
  /* Titre = 1ère colonne */
  th:nth-child(1), td:nth-child(1) { display: table-cell; }
  /* Genre = 2ème */
  th:nth-child(2), td:nth-child(2) { display: table-cell; }
  /* 3ème colonne (studio, auteur, réalisateur...) */
  /*th:nth-child(3), td:nth-child(3) { display: table-cell; }*/
  /* 4ème colonne (saison, tome...) */
  /*th:nth-child(4), td:nth-child(4) { display: table-cell; }*/
  /* Note = toujours avant-dernière ou cherchée — on affiche les 2 dernières */
  th:nth-last-child(2), td:nth-last-child(2) { display: table-cell; }
  /* Actions = dernière colonne */
  th:last-child, td:last-child { display: table-cell; }

  .form-grid { grid-template-columns: 1fr; gap: 10px; }

  /* --- Modal --- */
  .modal { padding: 0; align-items: flex-end; }
  .modal-card {
    border-radius: 16px 16px 0 0;
    max-height: 90vh;
    width: 100%;
    max-width: 100%;
  }
  .modal-header { padding: 16px 20px; }
  #item-form { padding: 16px 20px; }

  /* --- Todos --- */
  .todos-tabs { padding: 12px 16px 0; gap: 6px; }
  .todo-tab { padding: 8px 14px; font-size: 13px; }
  .todos-container { padding: 12px 16px; }
  .todo-input-row { flex-direction: row; }
  .todo-item { padding: 10px 12px; }

  /* --- Notes --- */
  .notes-layout {
    flex-direction: column;
    height: auto;
    position: relative;
  }

  /* Sur mobile les notes fonctionnent en 2 écrans :
     - liste des notes (par défaut)
     - éditeur (quand une note est ouverte) */
  .notes-sidebar {
    width: 100%;
    max-height: none;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }

  /* Quand une note est ouverte sur mobile, on cache la sidebar et on pleine-écrane l'éditeur */
  .notes-layout.note-open .notes-sidebar {
    display: none;
  }

  .notes-layout.note-open .notes-editor {
    position: fixed;
    inset: 0;
    bottom: 56px; /* par-dessus la bottom nav */
    z-index: 90;
    background: var(--bg);
    display: flex;
    flex-direction: column;
  }

  .notes-sidebar-header { padding: 14px 14px 10px; }
  #note-search { margin: 6px 10px; }

  #editor-content { height: 100%; }
  #editor-panels { flex: 1; overflow: hidden; }

  .editor-toolbar {
    padding: 10px 14px;
    gap: 6px;
    flex-wrap: wrap;
  }

  /* Bouton retour mobile (visible seulement sur mobile) */
  .note-back-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 14px;
    font-weight: 600;
    color: var(--primary);
    padding: 4px 0;
    background: none;
    border: none;
    cursor: pointer;
  }

  .note-title-input { font-size: 15px; min-width: 0; }

  .editor-actions { gap: 6px; }
  .editor-actions .btn-ghost { padding: 6px 10px; font-size: 12px; }
  .editor-actions #note-save-btn { padding: 6px 12px; font-size: 12px; }

  .note-body-input { padding: 16px; font-size: 13px; }
  .note-preview { padding: 16px; font-size: 14px; }

  .editor-meta { font-size: 11px; padding: 6px 14px; }

  /* Masquer le badge lié sur mobile dans la toolbar (visible dans la liste) */
  .linked-badge { max-width: 120px; overflow: hidden; text-overflow: ellipsis; font-size: 11px; }
}

/* ============ ADMIN ============ */
.impersonate-banner {
  background: linear-gradient(90deg, #f59e0b, #fbbf24);
  color: #1a1a1a;
  padding: 10px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 13px;
  font-weight: 600;
  position: sticky;
  top: 0;
  z-index: 60;
}
.impersonate-banner button {
  background: rgba(0,0,0,0.15);
  color: #1a1a1a;
  padding: 5px 12px;
  border-radius: 6px;
  font-weight: 700;
  font-size: 12px;
  margin-left: auto;
}
.impersonate-banner button:hover { background: rgba(0,0,0,0.25); }

.admin-intro {
  color: var(--text-dim);
  font-size: 13px;
  margin-bottom: 16px;
  max-width: 700px;
}

#admin-table th, #admin-table td { white-space: nowrap; }

@media (max-width: 768px) {
  .impersonate-banner { font-size: 12px; padding: 8px 12px; flex-wrap: wrap; }
  .impersonate-banner button { margin-left: 0; }
  #admin-table { font-size: 11px; }
  #admin-table th, #admin-table td { padding: 6px 8px; }
}

/* ============================================================
   NOUVELLE VERSION : post-it dashboard, tops, archivées
   ============================================================ */

/* --- Dashboard 2 colonnes --- */
.home-layout {
  display: flex;
  gap: 24px;
  align-items: flex-start;
}
.home-main { flex: 1; min-width: 0; }
.home-postit {
  width: 320px;
  flex-shrink: 0;
  position: sticky;
  top: 24px;
}

/* --- Post-it --- */
.postit-card {
  background: linear-gradient(145deg, #2a2f3d, #232733);
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 8px 24px rgba(0,0,0,0.25);
}
.postit-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
}
.postit-tab {
  flex: 1;
  padding: 12px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-dim);
  transition: all 0.15s;
}
.postit-tab.active {
  color: var(--primary);
  background: var(--primary-soft);
}
.postit-add {
  display: flex;
  gap: 6px;
  padding: 12px;
  border-bottom: 1px solid var(--border);
}
.postit-add input {
  flex: 1;
  padding: 8px 10px;
  font-size: 13px;
}
.postit-add button {
  width: 36px;
  background: var(--primary);
  color: white;
  border-radius: 8px;
  font-size: 20px;
  font-weight: 600;
}
.postit-add button:hover { background: var(--primary-hover); }
.postit-list {
  list-style: none;
  max-height: 420px;
  overflow-y: auto;
  padding: 8px;
}
.postit-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border-radius: 8px;
  transition: background 0.1s;
  animation: fadeIn 0.2s ease;
}
.postit-item:hover { background: rgba(255,255,255,0.03); }
.postit-check {
  width: 18px; height: 18px;
  border-radius: 5px;
  border: 2px solid var(--border);
  cursor: pointer;
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px;
  transition: all 0.15s;
}
.postit-check:hover { border-color: var(--success); }
.postit-text {
  flex: 1;
  font-size: 13px;
  line-height: 1.4;
}
.postit-empty {
  padding: 24px 12px;
  text-align: center;
  color: var(--text-dim);
  font-size: 13px;
  font-style: italic;
}
.postit-footer {
  padding: 10px 14px;
  font-size: 12px;
  color: var(--text-dim);
  border-top: 1px solid var(--border);
}

/* --- Tops --- */
.tops-selector {
  display: flex;
  gap: 16px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}
.tops-selector label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
  color: var(--text-dim);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}
.tops-selector select { min-width: 180px; }

.tops-layout {
  display: flex;
  gap: 24px;
  align-items: flex-start;
}
.top-ranking { flex: 1; min-width: 0; }
.top-candidates {
  width: 320px;
  flex-shrink: 0;
}
.top-ranking h3, .top-candidates h3 {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 14px;
}

.top-list {
  list-style: none;
  counter-reset: rank;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.top-item {
  counter-increment: rank;
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 16px;
  transition: all 0.15s;
}
.top-item::before {
  content: counter(rank);
  font-size: 18px;
  font-weight: 800;
  color: var(--primary);
  min-width: 28px;
  text-align: center;
}
.top-item:nth-child(1)::before { content: '🥇'; }
.top-item:nth-child(2)::before { content: '🥈'; }
.top-item:nth-child(3)::before { content: '🥉'; }
.top-item-title { flex: 1; font-weight: 600; font-size: 14px; }
.top-item-rating {
  font-size: 12px;
  font-weight: 600;
  color: var(--warning);
}
.top-item-actions { display: flex; gap: 4px; }
.top-move, .top-remove {
  padding: 4px 8px;
  border-radius: 6px;
  color: var(--text-dim);
  font-size: 14px;
  transition: all 0.15s;
}
.top-move:hover { background: var(--bg-elev); color: var(--text); }
.top-remove:hover { background: rgba(239,68,68,0.1); color: var(--danger); }

.top-empty {
  padding: 40px 20px;
  text-align: center;
  color: var(--text-dim);
  border: 2px dashed var(--border);
  border-radius: 12px;
}
.top-empty p { margin-bottom: 6px; }

.top-candidates-list {
  list-style: none;
  max-height: 500px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 12px;
}
.top-candidate {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  cursor: pointer;
  transition: all 0.15s;
}
.top-candidate:hover { border-color: var(--primary); background: var(--bg-soft); }
.top-candidate.in-top { opacity: 0.4; pointer-events: none; }
.top-candidate-title { font-size: 13px; font-weight: 500; flex: 1; }
.top-candidate-add {
  font-size: 18px;
  color: var(--primary);
  font-weight: 600;
}
#top-search { margin-bottom: 0; }

/* --- Todo archivées --- */
.todo-item.archived-item { opacity: 0.7; }
.todo-unarchive {
  opacity: 0;
  padding: 4px 8px;
  border-radius: 6px;
  color: var(--text-dim);
  font-size: 14px;
  transition: all 0.15s;
}
.todo-item:hover .todo-unarchive { opacity: 1; }
.todo-unarchive:hover { color: var(--primary); background: var(--primary-soft); }

/* --- Responsive --- */
@media (max-width: 900px) {
  .home-layout { flex-direction: column; }
  .home-postit { width: 100%; position: static; }
  .tops-layout { flex-direction: column; }
  .top-candidates { width: 100%; }
}

/* ============================================================
   MUSCU
   ============================================================ */

.muscu-tab {
  padding: 12px 18px;
  color: var(--text-dim);
  font-weight: 500;
  font-size: 14px;
  white-space: nowrap;
  border-bottom: 2px solid transparent;
  transition: all 0.15s;
  margin-bottom: -1px;
}
.muscu-tab:hover { color: var(--text); }
.muscu-tab.active { color: var(--primary); border-bottom-color: var(--primary); }

.muscu-view { animation: fadeIn 0.2s ease; }

/* --- Cartes de stats --- */
.muscu-stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  margin-bottom: 24px;
}
.muscu-stat {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  text-align: center;
}
.muscu-stat-value {
  font-size: 28px;
  font-weight: 800;
  color: var(--primary);
  line-height: 1.1;
}
.muscu-stat-label {
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 6px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  font-weight: 600;
}

/* --- Panneaux --- */
.muscu-panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 20px;
}
.muscu-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 18px;
  gap: 12px;
  flex-wrap: wrap;
}
.muscu-panel-header h3 {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.muscu-panel-header select { width: auto; min-width: 180px; font-size: 13px; }

.muscu-two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

/* --- Graphiques (SVG inline) --- */
.muscu-chart {
  width: 100%;
  min-height: 200px;
  overflow-x: auto;
}
.muscu-chart svg { display: block; width: 100%; height: auto; }
.chart-empty {
  padding: 50px 20px;
  text-align: center;
  color: var(--text-dim);
  font-size: 13px;
}

/* --- Calendrier --- */
.cal-nav {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  font-weight: 600;
}
#cal-label { min-width: 120px; text-align: center; }

.muscu-calendar {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}
.cal-dow {
  text-align: center;
  font-size: 11px;
  color: var(--text-dim);
  font-weight: 700;
  padding: 6px 0;
  text-transform: uppercase;
}
.cal-day {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  font-size: 13px;
  color: var(--text-dim);
  background: var(--bg-soft);
  transition: all 0.15s;
}
.cal-day.empty { background: transparent; }
.cal-day.has-workout {
  background: var(--primary);
  color: white;
  font-weight: 700;
  cursor: pointer;
}
.cal-day.has-workout:hover { background: var(--primary-hover); transform: scale(1.08); }
.cal-day.today {
  border: 2px solid var(--warning);
  color: var(--warning);
  font-weight: 700;
}
.cal-day.today.has-workout { color: white; }

/* --- Groupes musculaires --- */
.muscu-groups { display: flex; flex-direction: column; gap: 10px; }
.muscu-group-row {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 13px;
}
.muscu-group-name { min-width: 110px; font-weight: 600; }
.muscu-group-bar {
  flex: 1;
  height: 8px;
  background: var(--bg-soft);
  border-radius: 4px;
  overflow: hidden;
}
.muscu-group-fill {
  height: 100%;
  background: var(--primary);
  border-radius: 4px;
  transition: width 0.3s ease;
}
.muscu-group-count { min-width: 30px; text-align: right; color: var(--text-dim); font-weight: 600; }

/* --- Historique des séances --- */
.workout-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.workout-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px 20px;
  cursor: pointer;
  transition: all 0.15s;
}
.workout-card:hover { border-color: var(--primary); transform: translateY(-1px); }
.workout-card-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  gap: 12px;
  flex-wrap: wrap;
}
.workout-card-date {
  font-weight: 700;
  font-size: 15px;
}
.workout-card-name {
  color: var(--primary);
  font-size: 13px;
  background: var(--primary-soft);
  padding: 3px 10px;
  border-radius: 20px;
  font-weight: 600;
}
.workout-card-stats {
  display: flex;
  gap: 16px;
  font-size: 12px;
  color: var(--text-dim);
  flex-wrap: wrap;
}
.workout-card-stats strong { color: var(--text); }
.workout-card-exercises {
  margin-top: 10px;
  font-size: 12px;
  color: var(--text-dim);
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.workout-ex-chip {
  background: var(--bg-soft);
  padding: 3px 9px;
  border-radius: 6px;
  border: 1px solid var(--border);
}

/* --- Modal séance --- */
.workout-modal-card { max-width: 760px; }
.workout-form { padding: 20px 24px; overflow-y: auto; }

.workout-meta {
  display: grid;
  grid-template-columns: 180px 1fr;
  gap: 14px;
  margin-bottom: 22px;
}
.workout-meta label,
.workout-notes-label {
  display: block;
  font-size: 12px;
  color: var(--text-dim);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}
.workout-meta label input { margin-top: 5px; }
.workout-notes-label { margin-top: 18px; }
.workout-notes-label textarea { margin-top: 5px; min-height: 60px; resize: vertical; }

.workout-exercises-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}
.workout-exercises-header h3 {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.workout-exercises { display: flex; flex-direction: column; gap: 12px; }

.workout-empty {
  padding: 30px 20px;
  text-align: center;
  color: var(--text-dim);
  font-size: 13px;
  border: 2px dashed var(--border);
  border-radius: 10px;
}

.wex-card {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
  animation: fadeIn 0.2s ease;
}
.wex-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}
.wex-name { flex: 1; font-weight: 700; font-size: 14px; }
.wex-group {
  font-size: 11px;
  color: var(--text-dim);
  background: var(--bg-elev);
  padding: 2px 8px;
  border-radius: 5px;
}
.wex-remove {
  padding: 4px 8px;
  border-radius: 6px;
  color: var(--text-dim);
  font-size: 14px;
}
.wex-remove:hover { color: var(--danger); background: rgba(239,68,68,0.1); }

.wex-sets { display: flex; flex-direction: column; gap: 6px; }
.wex-set-header {
  display: grid;
  grid-template-columns: 34px 1fr 1fr 34px;
  gap: 8px;
  font-size: 10px;
  color: var(--text-dim);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  padding: 0 2px;
}
.wex-set {
  display: grid;
  grid-template-columns: 34px 1fr 1fr 34px;
  gap: 8px;
  align-items: center;
}
.wex-set-num {
  font-size: 13px;
  font-weight: 700;
  color: var(--primary);
  text-align: center;
}
.wex-set input {
  padding: 7px 10px;
  font-size: 13px;
  text-align: center;
}
.wex-set-del {
  padding: 4px;
  border-radius: 5px;
  color: var(--text-dim);
  font-size: 13px;
}
.wex-set-del:hover { color: var(--danger); }
.wex-add-set {
  margin-top: 8px;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--primary);
  background: var(--primary-soft);
  align-self: flex-start;
}
.wex-add-set:hover { background: rgba(99,102,241,0.25); }

.workout-summary {
  margin-top: 18px;
  padding: 12px 16px;
  background: var(--bg-soft);
  border-radius: 8px;
  font-size: 13px;
  color: var(--text-dim);
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
}
.workout-summary strong { color: var(--primary); font-weight: 700; }

/* --- Picker d'exercice --- */
.exercise-picker-list {
  max-height: 340px;
  overflow-y: auto;
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.exercise-group-title {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 10px 4px 4px;
}
.exercise-option {
  padding: 9px 12px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: background 0.1s;
}
.exercise-option:hover { background: var(--bg-soft); }
.exercise-custom-badge {
  font-size: 10px;
  color: var(--primary);
  background: var(--primary-soft);
  padding: 2px 6px;
  border-radius: 4px;
}

.exercise-create-zone {
  margin-top: 14px;
  padding: 14px;
  background: var(--bg-soft);
  border-radius: 10px;
  border: 1px dashed var(--primary);
}
.exercise-create-zone p { font-size: 13px; margin-bottom: 10px; }
.exercise-create-zone select { margin-bottom: 10px; }

/* --- Responsive muscu --- */
@media (max-width: 900px) {
  .muscu-two-col { grid-template-columns: 1fr; }
}
@media (max-width: 768px) {
  .muscu-stats-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .muscu-stat { padding: 14px; }
  .muscu-stat-value { font-size: 22px; }
  .muscu-panel { padding: 14px; }
  .workout-meta { grid-template-columns: 1fr; }
  .muscu-tab { padding: 10px 12px; font-size: 12px; }
  .wex-set-header, .wex-set { grid-template-columns: 28px 1fr 1fr 30px; gap: 6px; }
  .cal-day { font-size: 11px; }
}
