:root {
  --green:      #2e7d32;
  --green-dark: #1b5e20;
  --green-light:#e8f5e9;
  --yellow:     #f4c542;
  --text:       #1a1a1a;
  --text-muted: #5f6368;
  --border:     #e0e0e0;
  --bg:         #f4f5f7;
  --card:       #ffffff;
  --sidebar-w:  260px;
  --radius:     10px;
  --shadow:     0 2px 10px rgba(0,0,0,.08);
}

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

body {
  font-family: 'Segoe UI', Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
}

/* ── LOGIN ── */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--green-dark) 0%, var(--green) 100%);
  padding: 1rem;
}
.login-box {
  background: #fff;
  border-radius: 18px;
  padding: 2.5rem 2rem;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 24px 64px rgba(0,0,0,.2);
  text-align: center;
}
.login-logo { height: 56px; margin-bottom: 1rem; }
.login-title { font-size: 20px; font-weight: 800; color: var(--green-dark); margin-bottom: .3rem; }
.login-sub   { font-size: 13px; color: var(--text-muted); margin-bottom: 1.6rem; }
.login-box input {
  width: 100%; padding: 11px 14px;
  border: 1.5px solid var(--border); border-radius: 8px;
  font-size: 14px; margin-bottom: 10px; outline: none;
  transition: border-color .15s;
}
.login-box input:focus { border-color: var(--green); }
.login-box button {
  width: 100%; padding: 12px;
  background: var(--green); color: #fff;
  border: none; border-radius: 8px;
  font-size: 15px; font-weight: 700; cursor: pointer;
  transition: background .15s;
}
.login-box button:hover { background: var(--green-dark); }
.login-error { color: #c62828; font-size: 13px; margin-top: 10px; min-height: 18px; }

/* ── LAYOUT ── */
.layout { display: flex; min-height: 100vh; }

/* ── SIDEBAR ── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--green-dark);
  color: #fff;
  display: flex;
  flex-direction: column;
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 200;
  overflow-y: auto;
  transition: transform .25s ease;
}
.sidebar-header {
  display: flex; align-items: center; gap: 10px;
  padding: 1.2rem 1rem;
  border-bottom: 1px solid rgba(255,255,255,.1);
  text-decoration: none; color: #fff;
}
.sidebar-logo { height: 36px; }
.sidebar-brand { font-size: 13px; font-weight: 800; line-height: 1.3; }
.sidebar-brand-sub { font-size: 11px; opacity: .7; font-weight: 400; }

.sidebar-search {
  padding: .7rem 1rem;
  border-bottom: 1px solid rgba(255,255,255,.1);
}
.sidebar-search input {
  width: 100%; padding: 7px 10px;
  background: rgba(255,255,255,.12); border: none;
  border-radius: 6px; color: #fff; font-size: 13px; outline: none;
  -webkit-appearance: none;
}
.sidebar-search input::placeholder { color: rgba(255,255,255,.5); }

.sidebar-nav { flex: 1; padding: .5rem 0; }
.sidebar-cat-title {
  font-size: 10px; font-weight: 900; text-transform: uppercase;
  letter-spacing: 1.2px; color: rgba(255,255,255,.5);
  padding: .8rem 1rem .3rem;
}
.sidebar-link {
  display: block; width: 100%;
  padding: 7px 1rem 7px 1.2rem;
  font-size: 13px; color: rgba(255,255,255,.85);
  background: none; border: none; text-align: left;
  cursor: pointer; border-radius: 0;
  transition: background .12s, color .12s;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sidebar-link:hover  { background: rgba(255,255,255,.1); color: #fff; }
.sidebar-link.active { background: rgba(255,255,255,.18); color: #fff; font-weight: 700; }

.sidebar-footer {
  padding: 1rem;
  border-top: 1px solid rgba(255,255,255,.1);
  display: flex; flex-direction: column; gap: 6px;
}
.sidebar-user { font-size: 12px; opacity: .7; }
.session-timer { font-size: 11px; color: rgba(255,255,255,.4); font-family: monospace; }
.btn-logout {
  background: rgba(255,255,255,.12); border: none; color: #fff;
  padding: 7px 12px; border-radius: 7px; font-size: 13px;
  cursor: pointer; text-align: left;
}
.btn-logout:hover { background: rgba(255,255,255,.2); }

/* ── MAIN ── */
.main {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.topbar {
  background: #fff;
  border-bottom: 1px solid var(--border);
  padding: .9rem 1.5rem;
  display: flex; align-items: center; gap: 12px;
  position: sticky; top: 0; z-index: 100;
  box-shadow: 0 1px 6px rgba(0,0,0,.06);
}
.topbar-title { font-size: 17px; font-weight: 800; flex: 1; letter-spacing: -.2px; }
.topbar-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

.btn-primary {
  background: var(--green); color: #fff;
  border: none; border-radius: 9px;
  padding: 9px 18px; font-size: 13px; font-weight: 700;
  cursor: pointer; transition: background .15s, transform .1s, box-shadow .15s;
  box-shadow: 0 2px 6px rgba(46,125,50,.25);
}
.btn-primary:hover { background: var(--green-dark); box-shadow: 0 4px 12px rgba(46,125,50,.35); }
.btn-primary:active { transform: scale(.97); }
.btn-danger {
  background: #c62828; color: #fff;
  border: none; border-radius: 9px;
  padding: 9px 18px; font-size: 13px; font-weight: 700;
  cursor: pointer; transition: background .15s;
}
.btn-danger:hover { background: #b71c1c; }
.btn-secondary {
  background: #f1f3f4; color: var(--text);
  border: 1.5px solid var(--border); border-radius: 9px;
  padding: 8px 16px; font-size: 13px; font-weight: 600;
  cursor: pointer; transition: background .12s, border-color .12s;
}
.btn-secondary:hover { background: #e8eaed; border-color: #bbb; }

/* ── CONTENT AREA ── */
.content-area {
  flex: 1;
  padding: 2rem 2.5rem;
  max-width: 900px;
}

/* ── PAGE VIEW ── */
.page-view h1 { font-size: 26px; font-weight: 900; margin-bottom: .4rem; color: var(--green-dark); }
.page-meta { font-size: 12px; color: var(--text-muted); margin-bottom: 1.8rem; }
.page-body { font-size: 15px; line-height: 1.8; color: var(--text); }
.page-body h1 { font-size: 22px; font-weight: 800; margin: 1.4rem 0 .6rem; color: var(--green-dark); }
.page-body h2 { font-size: 18px; font-weight: 700; margin: 1.2rem 0 .5rem; color: var(--text); }
.page-body h3 { font-size: 15px; font-weight: 700; margin: 1rem 0 .4rem; }
.page-body p  { margin-bottom: .9rem; }
.page-body ul, .page-body ol { margin: .5rem 0 .9rem 1.4rem; }
.page-body li { margin-bottom: .3rem; }
.page-body strong { font-weight: 700; }
.page-body em     { font-style: italic; }
.page-body code {
  background: #f1f3f4; border-radius: 4px;
  padding: 2px 6px; font-family: monospace; font-size: 13px;
}
.page-body pre {
  background: #1a1a1a; color: #e8f5e9;
  border-radius: 10px; padding: 1rem 1.2rem;
  overflow-x: auto; margin: .8rem 0;
  font-family: monospace; font-size: 13px; line-height: 1.7;
}
.page-body pre code { background: none; padding: 0; color: inherit; }
.page-body blockquote {
  border-left: 4px solid var(--green);
  background: var(--green-light);
  padding: .8rem 1rem; border-radius: 0 8px 8px 0;
  margin: .8rem 0; color: var(--text);
}
.page-body hr { border: none; border-top: 2px solid var(--border); margin: 1.5rem 0; }
.page-body a { color: var(--green); text-decoration: underline; }

/* ── EDITOR ── */
.editor-wrap { display: flex; flex-direction: column; gap: 12px; }
.editor-wrap input[type="text"] {
  width: 100%; padding: 10px 14px;
  border: 1.5px solid var(--border); border-radius: 8px;
  font-size: 18px; font-weight: 700; outline: none;
  transition: border-color .15s;
}
.editor-wrap input[type="text"]:focus { border-color: var(--green); }
.editor-toolbar {
  display: flex; gap: 4px; flex-wrap: wrap;
  background: #f8f9fa; border: 1px solid var(--border);
  border-radius: 8px 8px 0 0; padding: 6px 8px;
}
.editor-toolbar button {
  background: none; border: 1px solid transparent;
  border-radius: 5px; padding: 4px 8px;
  font-size: 13px; cursor: pointer; color: var(--text);
  font-weight: 600; transition: background .1s;
}
.editor-toolbar button:hover { background: #e8eaed; border-color: var(--border); }
.editor-textarea {
  width: 100%; min-height: 420px; padding: 1rem;
  border: 1.5px solid var(--border); border-radius: 0 0 8px 8px;
  font-family: 'Courier New', monospace; font-size: 14px;
  line-height: 1.7; resize: vertical; outline: none;
  transition: border-color .15s; border-top: none;
}
.editor-textarea:focus { border-color: var(--green); }

/* ── WELCOME ── */
.welcome-card {
  background: #fff; border-radius: var(--radius);
  padding: 2rem; box-shadow: var(--shadow);
  border-left: 5px solid var(--green);
}
.welcome-card h2 { font-size: 20px; font-weight: 800; color: var(--green-dark); margin-bottom: .5rem; }
.welcome-card p  { color: var(--text-muted); font-size: 14px; }

/* ── ADMIN PANEL ── */
.admin-section { margin-bottom: 2rem; }
.admin-section-title {
  font-size: 14px; font-weight: 800; text-transform: uppercase;
  letter-spacing: .8px; color: var(--text-muted);
  margin-bottom: 1rem; padding-bottom: .5rem;
  border-bottom: 2px solid var(--border);
}
.admin-card {
  background: #fff; border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.2rem;
  margin-bottom: 10px; box-shadow: var(--shadow);
  display: flex; align-items: center; gap: 12px;
}
.admin-card-info { flex: 1; }
.admin-card-info strong { font-size: 14px; }
.admin-card-info span  { font-size: 12px; color: var(--text-muted); margin-left: 6px; }
.admin-card-actions { display: flex; gap: 6px; }

/* ── MODAL ── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.45); backdrop-filter: blur(4px);
  z-index: 1000; display: none;
  align-items: center; justify-content: center; padding: 1rem;
}
.modal-overlay.open { display: flex; }
.modal {
  background: #fff; border-radius: 16px;
  width: 100%; max-width: 480px;
  box-shadow: 0 32px 80px rgba(0,0,0,.22);
  animation: modalIn .18s ease;
}
@keyframes modalIn {
  from { opacity: 0; transform: translateY(12px) scale(.98); }
  to   { opacity: 1; transform: none; }
}
.modal-header {
  padding: 1.3rem 1.5rem .9rem;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.modal-title { font-size: 16px; font-weight: 800; }
.modal-close {
  background: #f1f3f4; border: none; font-size: 14px;
  cursor: pointer; color: var(--text-muted);
  width: 28px; height: 28px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  transition: background .12s;
}
.modal-close:hover { background: #e0e0e0; color: var(--text); }
.modal-body  { padding: 1.2rem 1.5rem; display: flex; flex-direction: column; gap: 10px; max-height: 70vh; overflow-y: auto; }
.modal-body label { font-size: 12px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: .4px; }
.modal-body input, .modal-body select {
  width: 100%; padding: 10px 13px;
  border: 1.5px solid var(--border); border-radius: 9px;
  font-size: 14px; outline: none; transition: border-color .15s, box-shadow .15s;
  background: #fff;
}
.modal-body input:focus, .modal-body select:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(46,125,50,.1);
}
.modal-body select[size] { padding: 4px; height: auto; overflow-y: auto; }
.modal-footer {
  padding: .9rem 1.5rem 1.3rem;
  display: flex; gap: 8px; justify-content: flex-end;
  border-top: 1px solid var(--border);
}

/* ── TOAST ── */
#toast {
  position: fixed; bottom: 24px; right: 24px;
  z-index: 9999; display: flex; flex-direction: column; gap: 8px;
}
.toast-item {
  padding: 11px 18px; border-radius: 10px;
  font-size: 14px; font-weight: 600; color: #fff;
  box-shadow: 0 4px 16px rgba(0,0,0,.2);
  animation: slideIn .2s ease;
}
.toast-item.success { background: var(--green); }
.toast-item.error   { background: #c62828; }
@keyframes slideIn { from { transform: translateY(12px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ── SIDEBAR TOGGLE ── */
.sidebar-toggle {
  display: none; background: none; border: none;
  font-size: 22px; cursor: pointer; padding: 4px 8px;
  min-width: 44px; min-height: 44px;
  display: none; align-items: center; justify-content: center;
}
.sidebar-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,.4); z-index: 199;
}

/* ── TABLETTE (≤ 1024px) ── */
@media(max-width: 1024px) {
  .content-area { padding: 1.5rem 1.5rem; }
  .library-grid { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }
}

/* ── MOBILE (≤ 700px) ── */
@media(max-width: 700px) {
  /* Sidebar */
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: none; }
  .sidebar-overlay.open { display: block; }
  .main { margin-left: 0; }
  .sidebar-toggle { display: flex; }
  .sidebar-link { padding: 10px 1rem 10px 1.2rem; }
  .sidebar-cat-btn { padding: 11px 1rem; }

  /* Topbar */
  .topbar { padding: .6rem .85rem; gap: 6px; flex-wrap: wrap; }
  .topbar-title {
    font-size: 14px; flex: 1;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    max-width: calc(100vw - 160px);
  }
  .topbar-actions {
    width: 100%; display: flex; gap: 6px;
    overflow-x: auto; padding-bottom: 2px;
    scrollbar-width: none;
  }
  .topbar-actions::-webkit-scrollbar { display: none; }
  .topbar-actions .btn-primary,
  .topbar-actions .btn-secondary {
    font-size: 12px; padding: 7px 11px;
    white-space: nowrap; flex-shrink: 0;
    min-height: 36px;
  }

  /* Content */
  .content-area { padding: 1rem .85rem; }

  /* Grille — 2 colonnes */
  .library-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .file-card { padding: .75rem; gap: 6px; }
  .file-icon { font-size: 28px; padding: 8px 0; }
  .file-name { font-size: 12px; }
  .file-meta { font-size: 10px; }
  .file-actions { gap: 5px; }
  .file-actions a, .file-actions button {
    padding: 9px 5px; font-size: 11px; min-height: 36px;
  }

  /* Library toolbar */
  .library-search { min-width: 0; }
  .library-filter { width: 100%; }

  /* Modal — slide depuis le bas */
  .modal-overlay { align-items: flex-end; padding: 0; }
  .modal {
    border-radius: 18px 18px 0 0;
    max-width: 100%; max-height: 92vh;
    display: flex; flex-direction: column;
  }
  .modal-body {
    overflow-y: auto;
    flex: 1;
  }
  .modal-body input, .modal-body select {
    font-size: 16px; /* évite zoom auto iOS */
    padding: 11px 12px;
  }

  /* Éditeur */
  .editor-content { min-height: 250px; font-size: 14px; padding: .9rem 1rem; }
  .editor-toolbar button { padding: 7px 9px; font-size: 12px; min-height: 34px; }

  /* Admin */
  .admin-card { flex-wrap: wrap; gap: 8px; }
  .admin-card-actions { width: 100%; justify-content: flex-end; }
  .admin-section-title { font-size: 12px; }

  /* Récents */
  .recent-icon { font-size: 22px; }
  .recent-name { font-size: 13px; }

  /* Toast */
  #toast { bottom: 14px; right: 14px; left: 14px; }
  .toast-item { font-size: 13px; }

  /* Upload zone */
  .upload-zone { padding: 1.2rem 1rem; }

  /* Session timer — masqué sur mobile */
  .session-timer { display: none; }

  /* Welcome */
  .welcome-card { padding: 1.2rem; }
}

/* ── PETIT TÉLÉPHONE (≤ 400px) ── */
@media(max-width: 400px) {
  .library-grid { grid-template-columns: 1fr; }
  .topbar-title { font-size: 13px; }
  .editor-title-row { flex-direction: column !important; }
  .editor-title-row input[type="number"] { width: 100% !important; }
}

/* ── ROLE BADGE ── */
.role-badge {
  display: inline-block; font-size: 10px; font-weight: 900;
  padding: 2px 8px; border-radius: 99px; text-transform: uppercase; letter-spacing: .5px;
}
.role-badge.super_admin { background: #7b1fa2; color: #fff; }
.role-badge.admin       { background: var(--green-dark); color: #fff; }
.role-badge.editor      { background: #1565c0; color: #fff; }
.role-badge.reader      { background: #f1f3f4; color: var(--text-muted); border: 1px solid var(--border); }

/* ── ADD PAGE BTN ── */
.new-page-btn {
  display: block; width: calc(100% - 2rem);
  margin: .5rem 1rem;
  padding: 7px 1rem; font-size: 13px;
  background: rgba(255,255,255,.1); color: rgba(255,255,255,.9);
  border: 1px dashed rgba(255,255,255,.3); border-radius: 7px;
  cursor: pointer; text-align: left; transition: background .12s;
}
.new-page-btn:hover { background: rgba(255,255,255,.18); }

/* ── BIBLIOTHÈQUE ── */
.library-toolbar {
  display: flex; gap: 10px; flex-wrap: wrap;
  align-items: center; margin-bottom: 1.4rem;
}
.library-search {
  flex: 1; min-width: 180px;
  padding: 8px 14px; border: 1.5px solid var(--border);
  border-radius: 8px; font-size: 13px; outline: none;
}
.library-search:focus { border-color: var(--green); }
.library-filter {
  padding: 8px 12px; border: 1.5px solid var(--border);
  border-radius: 8px; font-size: 13px; outline: none; background: #fff;
}
.library-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 16px;
}
.file-card {
  background: #fff;
  border: 1.5px solid var(--border);
  border-radius: 12px; padding: 1rem;
  display: flex; flex-direction: column; gap: 8px;
  box-shadow: 0 1px 4px rgba(0,0,0,.06);
  transition: box-shadow .18s, transform .18s, border-color .18s;
  position: relative; overflow: hidden;
}
.file-card::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px;
  background: linear-gradient(90deg, var(--green), #66bb6a);
  opacity: 0; transition: opacity .18s;
}
.file-card:hover {
  box-shadow: 0 6px 24px rgba(0,0,0,.11);
  transform: translateY(-2px);
  border-color: #c8e6c9;
}
.file-card:hover::before { opacity: 1; }
.file-icon {
  font-size: 36px; text-align: center;
  padding: 14px 0; background: var(--bg);
  border-radius: 8px;
}
.file-name {
  font-size: 13px; font-weight: 700; color: var(--text);
  line-height: 1.35; word-break: break-word;
}
.file-meta { font-size: 11px; color: var(--text-muted); line-height: 1.5; }
.file-actions { display: flex; gap: 6px; margin-top: auto; flex-wrap: wrap; }
.file-actions a, .file-actions button {
  flex: 1; padding: 7px 8px; border-radius: 8px;
  font-size: 12px; font-weight: 600; text-align: center;
  cursor: pointer; text-decoration: none; border: none;
  transition: background .12s, transform .1s; min-width: 0;
}
.file-actions a:active, .file-actions button:active { transform: scale(.96); }
.btn-view     { background: var(--green-light); color: var(--green-dark); }
.btn-view:hover { background: #c8e6c9; }
.btn-dl       { background: #e3f2fd; color: #1565c0; }
.btn-dl:hover { background: #bbdefb; }
.btn-del-sm   { background: #ffebee; color: #c62828; flex: 0; padding: 7px 10px; }
.btn-del-sm:hover { background: #ffcdd2; }

/* Upload zone */
.upload-zone {
  border: 2px dashed var(--border); border-radius: var(--radius);
  padding: 2rem; text-align: center; cursor: pointer;
  transition: border-color .15s, background .15s;
  background: #fafafa; margin-bottom: 1.4rem;
}
.upload-zone:hover, .upload-zone.drag { border-color: var(--green); background: var(--green-light); }
.upload-zone p { color: var(--text-muted); font-size: 13px; margin-top: 6px; }
.upload-progress {
  height: 6px; border-radius: 3px; background: #e0e0e0;
  margin-top: 10px; overflow: hidden; display: none;
}
.upload-progress-bar { height: 100%; background: var(--green); width: 0; transition: width .3s; }

/* ── SCROLLBAR SIDEBAR ── */
.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,.2); border-radius: 4px; }
.sidebar::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,.4); }
.sidebar { scrollbar-width: thin; scrollbar-color: rgba(255,255,255,.2) transparent; scrollbar-gutter: stable; }

/* ── ARBORESCENCE SIDEBAR ── */
.cat-group { border-bottom: 1px solid rgba(255,255,255,.06); }
.cat-edit-btn {
  background: none; border: none; color: transparent;
  cursor: pointer; font-size: 12px; padding: 2px 6px;
  border-radius: 4px; flex-shrink: 0; transition: color .12s;
}
.cat-group:hover .cat-edit-btn,
.cat-subs:hover .cat-edit-btn { color: rgba(255,255,255,.35); }
.cat-edit-btn:hover { color: #fff !important; background: rgba(255,255,255,.1); }
.sidebar-cat-btn {
  display: flex; align-items: center; justify-content: space-between;
  width: 100%; padding: 9px 1rem;
  background: none; border: none; color: rgba(255,255,255,.9);
  font-size: 13px; font-weight: 700; cursor: pointer; text-align: left;
  transition: background .12s;
}
.sidebar-cat-btn:hover { background: rgba(255,255,255,.08); }
.sidebar-cat-btn.open  { background: rgba(255,255,255,.1); color: #fff; }
.cat-arrow { font-size: 10px; opacity: .6; transition: transform .2s; }
.sidebar-cat-btn.open .cat-arrow { transform: rotate(90deg); }
.cat-subs { display: none; background: rgba(0,0,0,.18); }
.cat-subs.open { display: block; }
.sub-link { padding-left: 2.2rem !important; font-size: 13px !important; font-weight: 400 !important; color: rgba(255,255,255,.8) !important; }
.sub-link:hover { color: #fff !important; }
.sub-link.active { background: rgba(255,255,255,.16) !important; color: #fff !important; font-weight: 700 !important; border-left: 3px solid var(--yellow); }

/* ── ARBRE FICHIERS SIDEBAR ── */
.sub-row { display: flex; align-items: center; }
.sub-expand-btn {
  flex-shrink: 0; width: 28px; height: 30px;
  background: none; border: none; color: rgba(255,255,255,.35);
  cursor: pointer; font-size: 10px;
  display: flex; align-items: center; justify-content: center;
  transition: color .12s, transform .2s;
  margin-left: 6px;
}
.sub-expand-btn:hover { color: rgba(255,255,255,.75); }
.sub-expand-btn.expanded { transform: rotate(90deg); }
.sub-files { display: none; }
.sub-files.open { display: block; }
.sub-file-item {
  display: flex; align-items: center; gap: 6px;
  padding: 5px 12px 5px 38px;
  font-size: 11px; color: rgba(255,255,255,.65);
  text-decoration: none; background: none; border: none;
  width: 100%; text-align: left; cursor: pointer;
  transition: background .1s;
  white-space: nowrap; overflow: hidden;
}
.sub-file-item span { overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.sub-file-item:hover { background: rgba(255,255,255,.08); color: #fff; }
.sub-files-empty, .sub-files-loading {
  padding: 4px 12px 6px 38px;
  font-size: 11px; color: rgba(255,255,255,.25);
  font-style: italic;
}

/* ── ÉDITEUR DOCUMENT ── */
.toolbar-sep {
  display: inline-block; width: 1px;
  background: var(--border); margin: 0 4px; align-self: stretch;
}
.editor-content {
  width: 100%; min-height: 460px; padding: 1.2rem 1.4rem;
  border: 1.5px solid var(--border); border-radius: 0 0 8px 8px; border-top: none;
  font-family: 'Segoe UI', Arial, sans-serif; font-size: 15px;
  line-height: 1.8; outline: none; background: #fff; color: var(--text);
  transition: border-color .15s;
}
.editor-content:focus { border-color: var(--green); }
.editor-content:empty::before { content: 'Commence à écrire ici…'; color: #bbb; pointer-events: none; }
.editor-content h2 { font-size: 20px; margin: 1.2rem 0 .5rem; color: var(--green-dark); font-weight: 800; }
.editor-content h3 { font-size: 16px; margin: 1rem 0 .4rem; font-weight: 700; }
.editor-content p  { margin-bottom: .7rem; }
.editor-content ul, .editor-content ol { margin: .4rem 0 .7rem 1.5rem; }
.editor-content li { margin-bottom: .2rem; }

/* ── VUE À TRIER ── */
.unsorted-row {
  display: flex; align-items: center; gap: 12px;
  background: #fff; border: 1.5px solid var(--border);
  border-radius: 10px; padding: .75rem 1rem;
  margin-bottom: 8px; transition: background .15s;
}
.unsorted-row:hover { border-color: #c8e6c9; }
.unsorted-icon { font-size: 24px; flex-shrink: 0; width: 36px; text-align: center; }
.unsorted-info { flex: 1; min-width: 0; }
.unsorted-name { font-size: 13px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.unsorted-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; flex-wrap: wrap; justify-content: flex-end; }
.unsorted-cat-select {
  padding: 6px 10px; border: 1.5px solid var(--border); border-radius: 8px;
  font-size: 12px; outline: none; background: #fff;
  max-width: 240px; min-width: 160px;
  transition: border-color .15s;
}
.unsorted-cat-select:focus { border-color: var(--green); }
@media(max-width:700px) {
  .unsorted-row { flex-wrap: wrap; }
  .unsorted-cat-select { max-width: 100%; min-width: 100%; }
  .unsorted-actions { width: 100%; }
}

/* ── BADGE À TRIER ── */
.unsorted-badge {
  display: inline-flex; align-items: center; justify-content: center;
  background: #ff7043; color: #fff;
  font-size: 10px; font-weight: 900; min-width: 18px; height: 18px;
  padding: 0 5px; border-radius: 99px; margin-left: 5px;
}

/* ── BADGE ANNÉE ── */
.year-badge {
  position: absolute; bottom: 5px; right: 5px;
  background: rgba(27,94,32,.85); color: #fff;
  font-size: 10px; font-weight: 800; padding: 2px 7px;
  border-radius: 99px; pointer-events: none;
}

/* ── VUE RÉCENTS ── */
.recent-group { margin-bottom: 2rem; }
.recent-date {
  font-size: 11px; font-weight: 800; text-transform: uppercase;
  letter-spacing: 1px; color: var(--text-muted);
  padding-bottom: .5rem; margin-bottom: .5rem;
  border-bottom: 2px solid var(--border);
}
.recent-item {
  display: flex; align-items: center; gap: 12px;
  padding: .8rem 1rem; background: #fff;
  border: 1px solid var(--border); border-radius: var(--radius);
  margin-bottom: 8px; box-shadow: var(--shadow);
  text-decoration: none; color: var(--text);
  transition: box-shadow .12s, border-color .12s;
}
.recent-item:hover { box-shadow: 0 4px 16px rgba(0,0,0,.1); border-color: #bbb; }
.recent-icon { font-size: 28px; flex-shrink: 0; }
.recent-info { flex: 1; min-width: 0; }
.recent-name { font-size: 14px; font-weight: 700; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.recent-meta { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.recent-desc { font-weight: 400; color: var(--text-muted); }
.recent-year {
  background: var(--green-light); color: var(--green-dark);
  font-size: 11px; font-weight: 800; padding: 1px 8px;
  border-radius: 99px; border: 1px solid #a5d6a7;
}
