:root{font-family:system-ui,-apple-system,sans-serif;color:#21322d;background:#f4f7f5}*{box-sizing:border-box}body{margin:0}header{background:#174f46;color:white;padding:16px;display:flex;align-items:center;justify-content:space-between;gap:8px}header a{color:white;font-size:1.1rem;font-weight:750;text-decoration:none}header form{margin:0}main{max-width:720px;margin:auto;padding:20px 15px 50px}h1{font-size:1.7rem}h2{font-size:1.2rem}a{color:#176a58}form{display:grid;gap:12px}label{display:grid;gap:6px;font-weight:600}input,select,textarea{width:100%;font:inherit;border:1px solid #c7d6d0;border-radius:10px;padding:12px;background:white;min-height:46px}textarea{min-height:90px}button{border:0;background:#176a58;color:white;border-radius:10px;padding:12px 16px;font:inherit;font-weight:650;cursor:pointer}button.small{background:#366a61;padding:8px;font-size:.8rem}.search{grid-template-columns:1fr auto}.panel{background:white;border:1px solid #e0e8e4;border-radius:16px;padding:18px;margin-top:20px}.panel summary{font-weight:750;cursor:pointer}.panel form{margin-top:16px}.results{display:grid;gap:9px}.result{display:flex;align-items:center;gap:14px;padding:12px;background:white;border-radius:12px;text-decoration:none;color:inherit;border:1px solid #e1e8e4}.result img,.placeholder{width:60px;height:60px;object-fit:cover;border-radius:9px;background:#eaf2ef;display:grid;place-items:center;font-size:28px}.result span:nth-child(2){flex:1;min-width:0}.result small{display:block;color:#53655e;margin-top:4px}.muted{color:#68776f}.hero{width:100%;max-height:320px;object-fit:contain;border-radius:14px;background:white}.location{font-size:1.1rem;font-weight:700}.error{color:#b42318}


/* ARBORESCENCE — VERSION UNIFIÉE */

.rangement-tree {
  margin-bottom: 22px;
  overflow: visible;
}

.rangement-tree h2 {
  margin-top: 0;
}

.rangement-tree .tree-node {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 36px;
  column-gap: 8px;
  align-items: start;
  margin: 0;
  font-size: .95rem;
}

.rangement-tree .tree-node > details:not(.location-menu),
.rangement-tree .tree-node > .tree-leaf {
  grid-column: 1;
  grid-row: 1;
  min-width: 0;
  margin: 0;
}

.rangement-tree .tree-node > details:not(.location-menu) > summary,
.rangement-tree .tree-node > .tree-leaf {
  box-sizing: border-box;
  min-height: 40px;
  padding: 8px;
  border-radius: 8px;
  font-weight: 400;
  cursor: pointer;
}

.rangement-tree .tree-node > details:not(.location-menu) > summary:hover,
.rangement-tree .tree-node > .tree-leaf:hover {
  background: #f0f5f2;
}

.rangement-tree .tree-leaf {
  display: flex;
  align-items: center;
  gap: 8px;
}

.rangement-tree .tree-icon {
  display: inline-block;
  width: 24px;
  flex-shrink: 0;
  text-align: center;
  height: 24px;
  color: #176a58;
}

.rangement-tree .tree-node small {
  margin-left: 5px;
  color: #68776f;
  font-size: .75rem;
}

.rangement-tree .tree-children {
  margin: 4px 0 4px 18px;
  padding-left: 12px;
  border-left: 1px solid #dce5e1;
}

/* Menu d'actions : même hauteur que chaque ligne */

.rangement-tree .tree-node > .location-menu {
  grid-column: 2;
  grid-row: 1;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  align-self: start;
  width: 36px;
  height: 40px;
  margin: 0;
  padding: 0;
  overflow: visible;
}

.rangement-tree .location-menu > summary {
  box-sizing: border-box;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  min-height: 32px;
  margin: 0;
  padding: 0;
  border-radius: 8px;
  background: transparent;
  color: #526760;
  font-size: 20px;
  font-weight: 600;
  line-height: 1;
  list-style: none;
  cursor: pointer;
}

.rangement-tree .location-menu > summary::marker {
  content: "";
}

.rangement-tree .location-menu > summary::-webkit-details-marker {
  display: none;
}

.rangement-tree .location-menu > summary:hover,
.rangement-tree .location-menu[open] > summary {
  background: #edf3f0;
}

/* Menu déroulant */

.rangement-tree .location-menu-content {
  position: absolute;
  top: 40px;
  right: 0;
  z-index: 30;
  width: min(280px, 80vw);
  padding: 12px;
  border: 1px solid #dce5e1;
  border-radius: 12px;
  background: white;
  box-shadow: 0 8px 24px rgba(0,0,0,.12);
}

.rangement-tree .location-menu-content details {
  display: block;
  margin: 0 0 8px;
}

.rangement-tree .location-menu-content details > summary {
  display: list-item;
  padding: 9px 6px;
  font-weight: 600;
  cursor: pointer;
}

.rangement-tree .location-menu-content form {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
  margin: 6px 0 12px;
}

.rangement-tree .location-menu-content input,
.rangement-tree .location-menu-content select {
  width: 100%;
  min-width: 0;
}

.rangement-tree .location-menu-content button {
  width: 100%;
  margin: 0;
}

.rangement-tree .location-menu-content .menu-delete {
  background: #fff1f0;
  color: #a42620;
  border: 1px solid #f1cecb;
}

.rangement-tree .location-menu-content .menu-delete:hover {
  background: #ffe3e0;
}


.danger-zone {
  border-color: #edc8c8;
}

.danger-button {
  background: #b42318;
}

.danger-button:hover {
  background: #8f1c13;
}

.trash-link {
  color: white;
  text-decoration: none;
  font-size: .9rem;
  font-weight: 600;
}

.trash-link:hover {
  text-decoration: underline;
}

@media (max-width: 520px) {
  header {flex-wrap:wrap}
  .trash-link {font-size:.8rem}
}


.rangement-tree .tree-icon img {
  display: block;
  width: 20px;
  height: 20px;
  margin: 2px auto;
}


/* Sélecteur personnalisé d'icônes */

.rangement-tree .icon-choices {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin: 8px 0;
}

.rangement-tree .icon-choice {
  display: flex !important;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  min-width: 0;
  min-height: 72px;
  padding: 8px 4px;
  border: 1px solid #dce5e1;
  border-radius: 9px;
  background: #fff;
  cursor: pointer;
  font-size: 11px;
  font-weight: 500;
  text-align: center;
}

.rangement-tree .icon-choice:hover {
  background: #f0f5f2;
}

.rangement-tree .icon-choice:has(input:checked) {
  border-color: #176a58;
  background: #e7f3ed;
  box-shadow: inset 0 0 0 1px #176a58;
}

.rangement-tree .icon-choice input[type="radio"] {
  position: absolute;
  width: 1px;
  height: 1px;
  min-height: 0;
  padding: 0;
  margin: 0;
  border: 0;
  opacity: 0;
  pointer-events: none;
}

.rangement-tree .icon-choice:has(input:focus-visible) {
  outline: 2px solid #176a58;
  outline-offset: 2px;
}

.rangement-tree .icon-choice img {
  width: 22px;
  height: 22px;
}

.rangement-tree .icon-choice span {
  overflow-wrap: anywhere;
}


/* NAVIGATION ARBORESCENCE / DOSSIERS */

/* Respecter l'attribut hidden malgré les règles display */
#tree-view[hidden],
#folder-view[hidden] {
  display: none !important;
}

.navigation-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.navigation-header h2 {
  margin: 0;
}

.navigation-switch {
  display: flex;
  gap: 4px;
  padding: 4px;
  border-radius: 11px;
  background: #edf3f0;
}

.navigation-switch button {
  padding: 8px 12px;
  border-radius: 8px;
  background: transparent;
  color: #526760;
  font-size: .85rem;
  font-weight: 600;
}

.navigation-switch button.active {
  background: #176a58;
  color: white;
}

.navigation-switch button:focus-visible,
.folder-browser button:focus-visible {
  outline: 2px solid #176a58;
  outline-offset: 2px;
}

.folder-browser {
  min-height: 100px;
}

.folder-breadcrumb {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-bottom: 14px;
  color: #68776f;
}

.folder-breadcrumb button {
  padding: 5px 7px;
  border-radius: 6px;
  background: transparent;
  color: #176a58;
  font-size: .85rem;
  font-weight: 500;
}

.folder-breadcrumb button:hover {
  background: #edf3f0;
}

.folder-list {
  display: grid;
  gap: 8px;
}

.folder-entry {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 52px;
  padding: 10px 12px;
  border: 1px solid #e0e8e4;
  border-radius: 10px;
  background: white;
  color: #21322d;
  text-align: left;
}

.folder-entry:hover {
  background: #f0f5f2;
  border-color: #b9d5c8;
}

.folder-entry img {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
}

.folder-entry span:nth-child(2) {
  flex: 1;
  min-width: 0;
  overflow-wrap: anywhere;
}

.folder-entry span:last-child {
  color: #68776f;
  font-size: 22px;
  font-weight: 400;
}
