:root {
  --ink: #16221f;
  --ink-soft: #5b6b66;
  --ink-faint: #8a9a95;
  --line: #e3e8ee;
  --line-strong: #d3dbe6;
  --bg: #f5f7ff;
  --card: #ffffff;
  /* Palette reprise telle quelle de asai-front (globals.css) — bleu #2563eb comme
     accent principal, dégradé signature bleu -> violet pour les touches de marque. */
  --accent: #60a5fa;
  --accent-dark: #2563eb;
  --accent-violet: #a78bfa;
  --accent-soft: rgba(37, 99, 235, .1);
  --accent-gradient: linear-gradient(135deg, #60a5fa 0%, #a78bfa 100%);
  --danger: #c6432e;
  --danger-soft: rgba(198, 67, 46, .1);
  --success: #2f7d5e;
  --success-soft: rgba(47, 125, 94, .1);
  --radius: 10px;
  --radius-sm: 7px;
  --shadow-sm: 0 1px 2px rgba(22, 34, 31, .04);
  --shadow-md: 0 2px 10px rgba(22, 34, 31, .06);
  --shadow-lg: 0 8px 28px -8px rgba(22, 34, 31, .18);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  /* Fond gris-bleu doux, dégradé très subtil — même esprit que le fond de l'app JpEo. */
  background: linear-gradient(180deg, #f5f7ff 0%, #eef1f9 100%);
  background-attachment: fixed;
  color: var(--ink);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent-dark); }
::selection { background: var(--accent-soft); }
:focus-visible { outline: 2px solid var(--accent-dark); outline-offset: 2px; }

/* Sidebar et contenu défilent indépendamment l'un de l'autre : la coquille est
   verrouillée à la hauteur de l'écran (overflow ici, pas sur body, pour ne pas
   affecter les pages hors shell comme /login), chaque colonne gère son propre scroll. */
.shell { display: flex; height: 100vh; overflow: hidden; }

/* ── Sidebar ── */
.sidebar {
  width: 268px;
  flex-shrink: 0;
  background: rgba(255, 255, 255, .85);
  backdrop-filter: blur(14px);
  border-right: 1px solid var(--line);
  padding: 18px 0 14px;
  display: flex;
  flex-direction: column;
}
.sidebar .brand {
  padding: 2px 20px 16px;
  font-weight: 800;
  font-size: 15px;
  letter-spacing: -.01em;
  border-bottom: 1px solid var(--line);
  margin-bottom: 10px;
}
.sidebar .brand span {
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
/* ── Recherche floue (sidebar) ── */
.search-box { position: relative; padding: 0 12px 10px; }
.search-icon {
  position: absolute; left: 22px; top: 50%; transform: translateY(-50%);
  font-size: 13px; color: var(--ink-faint); pointer-events: none;
}
.search-box input {
  width: 100%; padding: 7px 40px 7px 28px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  font-size: 13px; background: var(--card); color: var(--ink);
  transition: border-color .12s ease, box-shadow .12s ease;
}
.search-box input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.search-kbd {
  position: absolute; right: 20px; top: 50%; transform: translateY(-50%);
  font-size: 10px; font-family: inherit; color: var(--ink-faint);
  background: var(--bg); border: 1px solid var(--line); border-radius: 4px; padding: 1px 5px;
  pointer-events: none;
}
.search-box input:focus ~ .search-kbd { display: none; }
.search-results {
  display: none; position: absolute; z-index: 20; left: 0; top: calc(100% - 4px);
  width: 720px; max-width: calc(100vw - 40px);
  background: var(--card); border: 1px solid var(--line-strong); border-radius: var(--radius);
  box-shadow: var(--shadow-lg); max-height: 60vh; overflow-y: auto; padding: 8px;
}
.search-results.open { display: block; }
.search-result { display: block; padding: 8px 10px; border-radius: var(--radius-sm); text-decoration: none; color: var(--ink); }
.search-result:hover, .search-result.active { background: rgba(37, 99, 235, .07); }
.search-result-title { font-size: 13px; font-weight: 700; margin-bottom: 2px; }
.search-result-snippet { font-size: 12px; color: var(--ink-soft); line-height: 1.45; }
.search-result-snippet mark { background: rgba(37, 99, 235, .18); color: var(--accent-dark); border-radius: 2px; padding: 0 1px; }
.search-empty { font-size: 12.5px; color: var(--ink-faint); padding: 10px; margin: 0; text-align: center; }

.sidebar nav { flex: 1; overflow-y: auto; padding-bottom: 8px; }

.nav-section { padding: 4px 0 8px; }

.page-link {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 20px 7px 10px;
  margin: 0 8px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  color: var(--ink-soft);
  text-decoration: none;
  cursor: grab;
  transition: background .12s ease, color .12s ease;
  user-select: none;
}
.page-link .grip {
  opacity: 0;
  color: var(--ink-faint);
  font-size: 11px;
  width: 12px;
  flex-shrink: 0;
  transition: opacity .12s ease;
}
.page-link:hover .grip { opacity: 1; }
.page-link .label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.page-link:hover { background: rgba(37, 99, 235, .06); color: var(--ink); }
.page-link.active {
  background: linear-gradient(135deg, rgba(37, 99, 235, .12), rgba(124, 58, 237, .08));
  color: var(--accent-dark);
  font-weight: 700;
}
.page-link.dragging { opacity: .4; }

.nav-groups { padding: 4px 0; }
.nav-group { margin-bottom: 2px; }
.nav-group.dragging { opacity: .4; }
.nav-group-header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 10px;
  margin: 0 8px;
  border-radius: var(--radius-sm);
  cursor: grab;
  user-select: none;
}
.nav-group-header:hover { background: rgba(37, 99, 235, .06); }
.nav-group-header .grip { opacity: 0; color: var(--ink-faint); font-size: 11px; width: 12px; flex-shrink: 0; transition: opacity .12s ease; }
.nav-group-header:hover .grip { opacity: 1; }
.nav-group-header .chevron { font-size: 9px; color: var(--ink-faint); transition: transform .15s ease; flex-shrink: 0; }
.nav-group.collapsed .chevron { transform: rotate(-90deg); }
.nav-group-header .group-name {
  flex: 1;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--ink-faint);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.nav-group-header .group-menu-btn {
  opacity: 0;
  background: none; border: none; cursor: pointer;
  color: var(--ink-faint);
  font-size: 13px;
  padding: 2px 4px;
  border-radius: 4px;
  line-height: 1;
}
.nav-group-header:hover .group-menu-btn { opacity: 1; }
.nav-group-header .group-menu-btn:hover { background: var(--line); color: var(--ink); }
.nav-group-pages { padding-bottom: 4px; min-height: 6px; }
.nav-group.collapsed .nav-group-pages { display: none; }
.nav-empty { font-size: 11px; color: var(--ink-faint); padding: 4px 20px 4px 26px; font-style: italic; margin: 0; }

.sidebar .user {
  padding: 12px 20px 0;
  border-top: 1px solid var(--line);
  margin-top: 10px;
  font-size: 12px;
  color: var(--ink-soft);
}
.sidebar .user a { color: var(--ink-soft); }

/* ── Main ── */
/* .main occupe toute la largeur restante jusqu'au bord du navigateur — c'est lui qui
   scrolle, donc sa scrollbar native reste collée à droite. .main-inner recentre et
   plafonne la largeur de lecture sans déplacer cette scrollbar. */
.main { flex: 1; min-width: 0; height: 100%; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.main-inner { max-width: 920px; margin: 0 auto; padding: 36px 44px; }

.topbar { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 26px; gap: 12px; flex-wrap: wrap; }
.topbar h1 { font-size: 23px; margin: 0; letter-spacing: -.01em; }
.topbar .meta { font-size: 12.5px; color: var(--ink-soft); margin-top: 5px; }

.btn {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--accent-dark); color: #fff; border: none;
  padding: 8px 16px; border-radius: 8px; font-size: 13px; font-weight: 600;
  text-decoration: none; cursor: pointer;
  transition: background .12s ease, transform .06s ease;
}
.btn:hover { background: #1d4ed8; }
.btn:active { transform: scale(.98); }
.btn.secondary { background: var(--card); color: var(--ink); border: 1px solid var(--line-strong); }
.btn.secondary:hover { background: var(--bg); border-color: var(--ink-faint); }
.btn.danger { background: var(--danger); }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 26px 30px; box-shadow: var(--shadow-sm); }

.doc-content h2 { font-size: 18px; margin: 26px 0 8px; letter-spacing: -.005em; }
.doc-content h2:first-child { margin-top: 0; }
.doc-content h3 { font-size: 15px; margin: 18px 0 6px; }
.doc-content p { margin: 0 0 12px; }
.doc-content ul, .doc-content ol { margin: 0 0 12px; padding-left: 22px; }
.doc-content li { margin-bottom: 4px; }
.doc-content code { background: #f0f0ea; padding: 1px 5px; border-radius: 4px; font-size: .9em; }
.doc-content blockquote { border-left: 3px solid var(--accent); margin: 14px 0; padding: 6px 16px; color: var(--ink-soft); background: var(--accent-soft); border-radius: 0 8px 8px 0; }

.empty-state { color: var(--ink-faint); font-size: 14px; text-align: center; padding: 60px 20px; }

.history-item { border-bottom: 1px solid var(--line); }
.history-item:last-child { border-bottom: none; }
.history-item summary::-webkit-details-marker { display: none; }
.history-item summary { padding: 13px 0; }
.history-item .who { color: var(--ink-soft); font-weight: 400; }

.login-wrap {
  display: flex; align-items: center; justify-content: center; min-height: 100vh;
  background: linear-gradient(180deg, #f5f7ff 0%, #eef1f9 100%);
}
.login-card { width: 380px; position: relative; overflow: hidden; }
.login-card::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 4px;
  background: var(--accent-gradient);
}
.login-card h1 { font-size: 19px; margin: 6px 0 6px; letter-spacing: -.01em; }
.login-card p { font-size: 13px; color: var(--ink-soft); margin: 0 0 20px; }
.login-card input[type="email"] {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line-strong); border-radius: 8px; font-size: 14px; margin-bottom: 12px;
  transition: border-color .12s ease;
}
.login-card input[type="email"]:focus { border-color: var(--accent); outline: none; }
.notice { font-size: 13px; padding: 10px 14px; border-radius: 8px; margin-bottom: 16px; line-height: 1.5; }
.notice.success { background: var(--success-soft); color: var(--success); }
.notice.error { background: var(--danger-soft); color: var(--danger); }

.field { margin-bottom: 14px; }
.field label { display: block; font-size: 11.5px; font-weight: 700; color: var(--ink-soft); margin-bottom: 5px; text-transform: uppercase; letter-spacing: .05em; }
.field input[type="text"] {
  width: 100%; padding: 9px 12px; border: 1px solid var(--line-strong); border-radius: 8px; font-size: 15px;
  transition: border-color .12s ease;
}
.field input[type="text"]:focus { border-color: var(--accent); outline: none; }

/* L'éditeur TinyMCE gère son propre style (skin "oxide") — le conteneur .tox-tinymce
   hérite juste de l'arrondi et de la bordure du reste de l'interface pour rester cohérent. */
.tox-tinymce { border-radius: var(--radius) !important; border-color: var(--line-strong) !important; box-shadow: var(--shadow-sm); }

@media (max-width: 720px) {
  .shell { flex-direction: column; }
  .sidebar { width: 100%; border-right: none; border-bottom: 1px solid var(--line); max-height: 40vh; }
  .main-inner { padding: 22px 18px; }
}
